Quantcast
Channel: How to Highlight Text
Viewing all articles
Browse latest Browse all 12

How to Highlight Text

$
0
0

Here's a good example that I put together as well.

Dim h_words As String() = {"one", "two", "three"}
For Each word As String In h_words
	For Each m As Match In Regex.Matches(RichTextBox1.Text, word, RegexOptions.IgnoreCase).OfType(Of Match)()
		RichTextBox1.Select(m.Index, m.Length)
		RichTextBox1.SelectionColor = Color.Red
	Next
Next

Possibly a bit faster as well for a few reasons, try it out and see :)

Provide the case statements or logic however you want based on the value of word as you see fit. (Around the line where you set the SelectionColor property.

Cheers
~Ace


If a post helps you in any way or solves your particular issue, please remember to use thePropose As Answer option or Vote As Helpful
Visit the Forum: TechLifeForum





Viewing all articles
Browse latest Browse all 12

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>