Consider my windows application built using C# VS 2005 displays certain contents in a Rich Text Box. Now when i add some new text, it should appear in a different colour. i.e i need to differentiate the text which gets displayed programmatically and the text that i enter in the text box. how can i do this.?
i.e the font color of the newly inserted text should be different from the text that is already displayed.
PS: Previously i have used text box and changed it to rich text box as told in the below thread. link text
From stackoverflow
-
IIRC, this works:
- Set the selection start index to the last character.
- Change selection color.
- Add new text.
- Reset selection color.
-
private void richTextBox1_KeyPress(object sender, KeyPressEventArgs e) { this.richTextBox1.SelectionColor = Color.Red; }Text inserted by keyboard is red.
0 comments:
Post a Comment