Reputation: 35
In VB.Net, is it possible to highlight ALL instances of a phrase instead of only a single instance of it, for example:
txtView.SelectionStart = txtView.Find("ERROR: Invalid command entered.")
txtView.SelectionColor = Color.Red
This would highlight "ERROR: Invalid command entered.", however if my RichTextBox text is:
ERROR: Invalid command entered. < Only this line will highlight
ERROR: Invalid command entered.
ERROR: Invalid command entered.
Alternatively, is there a way I can simply colour the line when I write it to the RichTextBox? Thanks in advance!
Upvotes: 1
Views: 1041
Reputation: 941327
Nope, there's is only one value for SelectionStart and SelectionLength. Yes, you can use the SelectionBackColor and SelectionColor properties to colorize the text that matches. You'll find sample code in my answer in this thread.
Upvotes: 1