0

I used the find function of a Rich Text Box and it works, however, it only finds the first match and I want it to find all matches instead.

How do I go about this?

        var C = new List<string>();

       DataTable dt = new DataTable();
       dt.Load(reader);
       foreach (DataRow dr in dt.Rows)
       {
           timer1.Enabled = false;


           q = dt.Rows[i]["Sender_Name"].ToString();
           w = dt.Rows[i]["Messege_Text"].ToString();

           richTextBox1.Text += "\n" + q + " : " + w;


           if (q == label2.Text)
           {
                   C.Add(q + " : " + w);
           }

           i++;
       }



       for (int o = 0; o < C.Count; o++)
       {

           richTextBox1.Find(C[o],RichTextBoxFinds.None);
           //richTextBox1.Find(C[o]);
           //MessageBox.Show(C[o]);
           richTextBox1.SelectionBackColor = Color.Cyan;
           richTextBox1.SelectionAlignment = HorizontalAlignment.Right;

       }

0 Answers0