Hi Jai
Below is a C# class file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace WindowsFormsApplication1
{
class Class1
{
public static void HighlightText(System.Windows.Forms.RichTextBox myRtb, string word, System.Drawing.Color color)
{
int s_start = myRtb.SelectionStart, startIndex = 0, index = 0;
System.Windows.Forms.RichTextBox myRtb1 = new System.Windows.Forms.RichTextBox();
myRtb1.Text = myRtb.Text.ToLower();
word = word.ToLower();
while ((index = myRtb1.Text.IndexOf(word, startIndex)) != -1)
{
myRtb.Select(index, word.Length);
myRtb.SelectionColor = color;
startIndex = index + word.Length;
}
myRtb.SelectionStart = s_start;
myRtb.SelectionLength = 0;
myRtb.SelectionColor = System.Drawing.Color.Black;
}
}
}
Call this function in your Search Button Click
Class1.HighlightText(richTextBox1, "wills", Color.Aqua);
<pre lang="c#">
Regards
Willington