In C #, how to change the color of newly added text in a textbox
Consider that my Windows application, built using C # VS 2005, displays certain content in a text box with multiple lines. Now when I add new text, it should appear in a different color. ie I need to distinguish between the text that is displayed when my project starts and the text that I entered in the textbox. How can i do this?
a source to share
A regular element TextBox
does not support multiple colors, fonts, etc.
I suspect you will need to use RichTextBox
. You can then set the property SelectionColor
to change the color of the current text or text pasted at the current insertion point.
I must add that after some quick experimentation, I found that setting the highlight color and then adding text programmatically did not work as straight forward as I hoped. Maybe another answer will explain why :) However, the text entered by the user necessarily appears in a new color right away ...
a source to share