Voici un contrôle .Net héritant de RichTextBox, permettant de surligner chaque occurence du mot recherché :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public static class RichTextBoxExtensions
    {
        public static void HighlightText(this RichTextBox richTextBox, string word, Color color){
			int startIndex = 0, index;
			richTextBox.Select(0,richTextBox.Text.Length);
			richTextBox.SelectionColor = richTextBox.ForeColor;
			if(word.Length==0)return;
 
                     while((index = richTextBox.Text.IndexOf(word, startIndex)) != -1)
                     {
                        richTextBox.Select(index, word.Length);
                        richTextBox.SelectionColor = color;
                        startIndex = index + word.Length;
                     }
                }
    }