flyingeagle855
MIS
I need to be able to change color by line as I add text to a RichTextBox here is the code I have so far.
if I comment out
then the text is red on the one line that was inserted using the
but if I try to add more text it makes all the text black. Any help would be great.
Code:
private void Updatetext_error(string text)
{
Font fBold = new Font("Tahoma", 8, FontStyle.Bold);
textBox1.SelectionStart = textBox1.Text.Length;
textBox1.SelectionFont = fBold;
textBox1.SelectionColor = Color.Red;
textBox1.SelectedText = text;
textBox1.SelectionStart = textBox1.Text.Length;
textBox1.Text += "\r\n Contact your system administrator";
textBox1.Select(textBox1.Text.Length - 1, textBox1.Text.Length - 1);
textBox1.ScrollToCaret();
}
if I comment out
Code:
textBox1.Text += "\r\n Contact your system administrator";
Code:
textBox1.SelectedText = text;