I have a list of words I want to highlight in my RichTextBox
control, I have an idea on how to do it but having a problem with parsing everything to separate words.
How can I parse a line or the whole text into separate words and then enumerate over them and color them using RichTextBox.Select()
method.
Is this a good way? Is there a better/faster way?
In C#, RichTextBox control is a textbox which gives you rich text editing controls and advanced formatting features also includes a loading rich text format (RTF) files. Or in other words, RichTextBox controls allows you to display or edit flow content, including paragraphs, images, tables, etc.
Syntax highlighting determines the color and style of source code displayed in the Visual Studio Code editor. It is responsible for colorizing keywords like if or for in JavaScript differently than strings and comments and variable names.
Use the RichTextBox.Find(String, Int32, Int32, RichTextBoxFinds) method to find your strings in the control. You can then iterate by changing the Start point to the point after the current word.
Not sure on the performance of this scheme but it will work.
http://msdn.microsoft.com/en-us/library/yab8wkhy.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With