richtextbox

Retain highlighted color of text after editing

喜欢而已 提交于 2021-02-05 11:52:36
问题 Cannot keep the highlighted effect I set in my RichTextBox on my text after removing content of a line in front of him. No matter how much text I remove from the control it always removes the custom SelectionColor and SelectionBackColor I set to a text already contained in it. Code of my Removal method: private void btnRemove_Click(object sender, EventArgs e) { //Remove selected line from RichTextBox richTextBox1.Text = richTextBox1.Text.Remove(richTextBox1.Text.Length - 1, 1); //Remove all

How to highlight a word or phrase with a color different from all the other selections in a RichTextBox text?

◇◆丶佛笑我妖孽 提交于 2021-02-05 07:56:27
问题 The main goal is to let an User identify a selection as the current, among all other selected words or phrases. private void numericUpDown1_ValueChanged(object sender, EventArgs e) { if (results.Count > 0) { richTextBox1.SelectionStart = results[(int)numericUpDown1.Value - 1]; richTextBox1.SelectionLength = textBox1.Text.Length; richTextBox1.SelectionColor = Color.Red; richTextBox1.ScrollToCaret(); } } In this case, in the screenshot, there are 3 results of the searched word: System . All the

How can I type half-space in RichTextBox?

做~自己de王妃 提交于 2021-02-05 05:12:50
问题 When I press "Shift + Space" to type half-space (when I 'm writing in Persian) in a RichTextBox, it just inserts space. It types all other Persian characters correctly, but when it comes to "Shift+Space", it types just space. The name of this character is "ZERO WIDTH NON-JOINER" and the information is given in this link: http://www.fileformat.info/info/unicode/char/200c/index.htm. I should mention that I fixed the problem by handling previewKewDown event; but I like to know what is the

How can I type half-space in RichTextBox?

心已入冬 提交于 2021-02-05 05:11:23
问题 When I press "Shift + Space" to type half-space (when I 'm writing in Persian) in a RichTextBox, it just inserts space. It types all other Persian characters correctly, but when it comes to "Shift+Space", it types just space. The name of this character is "ZERO WIDTH NON-JOINER" and the information is given in this link: http://www.fileformat.info/info/unicode/char/200c/index.htm. I should mention that I fixed the problem by handling previewKewDown event; but I like to know what is the

How can I type half-space in RichTextBox?

烈酒焚心 提交于 2021-02-05 05:10:51
问题 When I press "Shift + Space" to type half-space (when I 'm writing in Persian) in a RichTextBox, it just inserts space. It types all other Persian characters correctly, but when it comes to "Shift+Space", it types just space. The name of this character is "ZERO WIDTH NON-JOINER" and the information is given in this link: http://www.fileformat.info/info/unicode/char/200c/index.htm. I should mention that I fixed the problem by handling previewKewDown event; but I like to know what is the

How can I type half-space in RichTextBox?

对着背影说爱祢 提交于 2021-02-05 05:07:47
问题 When I press "Shift + Space" to type half-space (when I 'm writing in Persian) in a RichTextBox, it just inserts space. It types all other Persian characters correctly, but when it comes to "Shift+Space", it types just space. The name of this character is "ZERO WIDTH NON-JOINER" and the information is given in this link: http://www.fileformat.info/info/unicode/char/200c/index.htm. I should mention that I fixed the problem by handling previewKewDown event; but I like to know what is the

wpf richtextbox selection with regex

你离开我真会死。 提交于 2021-01-29 08:37:39
问题 i want to color the matched text of a file. first,i load the file text into FileItem.Content ,then use regex to get the matches,and next put the Content into a richtextbox and use the matches to set the caret position and color the text . and the code to fill richtextbox RtbCodes.Document.Blocks.Clear(); RtbCodes.Document.Blocks.Add(new Paragraph(new Run(item.Content))); foreach (Match m in item.Matches) { TextPointer start1 = RtbCodes.Document.ContentStart.GetPositionAtOffset(m.Index,

Why does RichTextBox implicitly add newline?

喜你入骨 提交于 2021-01-28 14:38:44
问题 I have class Foo derived from RichTextBox , which has private method add_text and I came across that it gives wrong results. For examples, instead of added text x it gives x\r\n . What is the problem of RichTextBox class? before usage of add_text method I cleared content with Document.Blocks.Clear() command // Appends text to the end with specified selection colors private void add_text(string text, Brush foreground_brush, Brush background_brush) { // here new TextRange(Document.ContentStart,

Why does RichTextBox implicitly add newline?

旧时模样 提交于 2021-01-28 14:31:39
问题 I have class Foo derived from RichTextBox , which has private method add_text and I came across that it gives wrong results. For examples, instead of added text x it gives x\r\n . What is the problem of RichTextBox class? before usage of add_text method I cleared content with Document.Blocks.Clear() command // Appends text to the end with specified selection colors private void add_text(string text, Brush foreground_brush, Brush background_brush) { // here new TextRange(Document.ContentStart,

Select text from a Richtextbox in C#

痞子三分冷 提交于 2021-01-27 21:34:49
问题 I want to select the text that is between the last '{' and '}' of a richtextbox text. I have the next code, but I have an error on the "LastIndexOf" function and I don't know how to fix it. Can someone give me some help? private void highlightText() { mRtbxOperations.SelectionStart = mRtbxOperations.Text.LastIndexOf(@"{", 1, mRtbxOperations.SelectionStart); mRtbxOperations.SelectionLength = mRtbxOperations.Text.IndexOf(@"}", mRtbxOperations.SelectionStart, mRtbxOperations.Text.Length - 1);