Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42448

Change HTML Tag Color

$
0
0
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:

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;
}

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

Viewing all articles
Browse latest Browse all 42448

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>