Hi Everyone,
I would like to know if there is any way to change the color of a part of text in rich textbox when the user types it automatically like the way in vb.net IDE (Classes have blue etc.).
Thanks in advance,
Yuvjeeth

Recommended Answers

I guess you're talking about Syntax Highlighting. You need to select that part of text by using SelectionStart & SelectionLength (from RichTextBox) and then, change it's color with SelectionColor.

As an example, this code makes the first 10 characters blue:

richTextBox1.SelectionStart = 0;
richTextBox1.SelectionLength = 10;
richTextBox1.SelectionColor …
Jump to Post

All 3 Replies

I guess you're talking about Syntax Highlighting. You need to select that part of text by using SelectionStart & SelectionLength (from RichTextBox) and then, change it's color with SelectionColor.

As an example, this code makes the first 10 characters blue:

richTextBox1.SelectionStart = 0;
richTextBox1.SelectionLength = 10;
richTextBox1.SelectionColor = Color.Blue;

but I want to highlight some parts of HTML document such as tags in my app. So how do I do that because all tag lengths are not equal

This may be helpfull.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.