I open up an HTML file in my program, and the file is read into a richTextBox. I'm trying to have the richTextBox find HTML tags and convert them to a different color so it will be easier to read. The code I've developed so far is:
Is there a more efficient way to go about this, instead of applying this code for every single tag? Considering some tags differ. For example, the <body> tag can be used like that or like <body style="background-color:orange">. Thank you
Code:
int len = this.richTextBox1.TextLength;
int index = 0;
int lastIndex = this.richTextBox1.Text.LastIndexOf("<html>");
while (index <= lastIndex)
{
this.richTextBox1.Find("<html>", index, len, RichTextBoxFinds.None);
this.richTextBox1.SelectionColor = Color.Red;
index = this.richTextBox1.Text.IndexOf("<html>", index) + 1;
}