Formatted RichTextBox in C#

Color color = System.Drawing.Color.Green;
var lines= richTextBox.Lines;
int index = 0;
foreach (string line in lines)
{
   var start = richTextBox.GetFirstCharIndexFromLine(index);  //Get the 1st char index of a line.
   var length = lines[index].Length;
   richTextBox.Select(start, length); //Select from there to the end
   richTextBox.SelectionColor = color;
   index++;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s