hi every body i am building a chat system i want if user send a message or recive a message the color of the nickname is blue in the richbox
A:
Coloring text inside a rich textbox is a matter of providing the input as RTF. Have a look at this article on how to do so http://www.codeproject.com/KB/cs/RTFSyntaxColour.aspx
Dror Helper
2010-01-17 11:54:42
+1
A:
Just use the SelectionColor property to change the color of the text:
private void button1_Click(object sender, EventArgs e) {
richTextBox1.AppendText("blahblah\n");
Color prev = richTextBox1.SelectionColor;
richTextBox1.SelectionColor = Color.Blue;
richTextBox1.AppendText("nobugz\n");
richTextBox1.SelectionColor = prev;
richTextBox1.AppendText("blahblah\n");
}
You can also use SelectionBackColor to change the background color.
Hans Passant
2010-01-17 13:57:03