Different font colors in RichTextBox
-
hi, in a client/server chat application the client can choose his fave font color and the server shld spread each client messages in its own unique font color. is there away to do that with the clients form displays messages in a richTextBox? (the only way i managed to do that is with listView) many thanks
-
hi, in a client/server chat application the client can choose his fave font color and the server shld spread each client messages in its own unique font color. is there away to do that with the clients form displays messages in a richTextBox? (the only way i managed to do that is with listView) many thanks
Hi! You'd have to use the SelectionColor property for that. For example, something like this should work:
richTextBox1.Select(startOfMessage, 0);
richTextBox1.SelectionColor = Color.Red;
richTextBox1.SelectedText = "Message from User 1" + Environment.Newline;
richTextBox1.SelectionColor = Color.Blue;
richTextBox1.SelectedText = "Second message from User 2" + Environment.Newline;Regards, mav -- Black holes are the places where God divided by 0...
-
Hi! You'd have to use the SelectionColor property for that. For example, something like this should work:
richTextBox1.Select(startOfMessage, 0);
richTextBox1.SelectionColor = Color.Red;
richTextBox1.SelectedText = "Message from User 1" + Environment.Newline;
richTextBox1.SelectionColor = Color.Blue;
richTextBox1.SelectedText = "Second message from User 2" + Environment.Newline;Regards, mav -- Black holes are the places where God divided by 0...