Logging Experiences

Code Snippet: Searching and Highlighting a token or string in a RichTextBox

Posted in C#, Programming, Snippets by Sina Iravanian on August 8, 2010

Suppose that you intend to find a string or a token (i.e., whole word, instead of a substring) and change their color in some RichTextBox. The following code snippets will help. The FindStringAndSetColor method looks for instances of an arbitrary string in the contents of the RichTextBox, while the FindTokenAndSetColor method looks for whole words (tokens).

Advertisements
Tagged with: , ,

One Response

Subscribe to comments with RSS.

  1. Ab Rahim said, on November 13, 2016 at 6:13 pm

    I was searching something similar….thanks man this solved my problem….


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: