ForeColor

solus

Freshman
Joined
Apr 5, 2003
Messages
30
Location
Phoenix
C#:
this.txtMsg.ForeColor = System.Drawing.Color.Black;

I have a multi-line TextBox that i'm appending with messages. I want to use different colored text for different types of messages. Obviously I can't set the ForeColor again, is there escape characters or something similar to use to accomplish this?
 
C#:
		public void foo()
		{
			string sometext = "bar";
			this.richTextBox1.Text += color;
			this.richTextBox1.Select((this.richTextBox1.Text.Length-sometext.Length), sometext.Length);
			this.richTextBox1.SelectionColor = System.Drawing.Color.Red;
			this.richTextBox1.Select(this.richTextBox1.Text.Length,0);
		}

This works. First I append the text, select it, change the color and put the cursor back at the end of the box.
 
Last edited:
Back
Top