Hi,
Can any one help with this…
I have to Richtextbox and I want to change the color of selected strings within the Richtextbox. I am able to do this with the code below. The trouble is if I call the function more than once then all the text in the text box changes to the color blue instead of just the selected string. Does any one know why this occurs or if there is a better way to do this?
Code:
Private sub ColorText(byVal MyString as string)
'Change string "SOMETEXT" to blue in richtextbox1
RichTextBox1.Text = MyString
RichTextBox1.SelectionStart = RichTextBox1.Find("SOMETEXT")
RichTextBox1.SelectionColor = Color.Blue
End sub
Thanks
Can any one help with this…
I have to Richtextbox and I want to change the color of selected strings within the Richtextbox. I am able to do this with the code below. The trouble is if I call the function more than once then all the text in the text box changes to the color blue instead of just the selected string. Does any one know why this occurs or if there is a better way to do this?
Code:
Private sub ColorText(byVal MyString as string)
'Change string "SOMETEXT" to blue in richtextbox1
RichTextBox1.Text = MyString
RichTextBox1.SelectionStart = RichTextBox1.Find("SOMETEXT")
RichTextBox1.SelectionColor = Color.Blue
End sub
Thanks