开发者

how to paint text on RichTextBox? [duplicate]

开发者_运维问答This question already has answers here: Closed 11 years ago.

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:

  1. Find out start position of the word
  2. Find out length of the word
  3. Select word by its start position and length (you should use SelectionStart and SelectionLength properties of RichTextBox)
  4. Managing selected word appearance by manipulations with SelectionFont, SelectionColor, SelectioStyle properties of your RichTextBox
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜