I can find a million examples of doing reg ex to apply syntax highlighting to a rich text box. but what i need it just a simple way to add in a word of a diffrent color.
What would the code be to just put the words "Hello World" into a textbox and have Hello be red and World be green?
This code doesnt work.
this.richTextBox1.SelectionColor = Color.Red
this.richTextBox1.text += "Test"
This code adds text "Hello" in red color and "World" in green to the RichTextBox.
RichTextBox1.SelectionColor = Color.Red
RichTextBox1.SelectedText = "Hello "
RichTextBox1.SelectionColor = Color.Green
RichTextBox1.SelectedText = "World"
Select the text after you put it in and then change the color.
For example:
richTextBox1.Text += "Test"
richTextBox1.Select(richTextBox1.TextLength - 4, 4)
richTextBox1.SelectionColor = Color.Red
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With