how to paint text on RichTextBox? [duplicate]
Possible Duplicate:
How to Syntax Highlight in a RichTextBox [C#]?
How do I paint in any "select" or "where" word green and any number in red when typing in a RichTextBox?
you can use the property of RichTextbox "Selectioncolor":
richTextBox.SelectionColor = Color.Red;
The main princip to word highlighting in RichTextBox box consist of steps:
- Find out start position of the word
- Find out length of the word
- Select word by its start position and length (you should use SelectionStart and SelectionLength properties of RichTextBox)
- Managing selected word appearance by manipulations with SelectionFont, SelectionColor, SelectioStyle properties of your RichTextBox
精彩评论