title: Highlight color in richtextbox
body: <pre><code>Public Sub textcolorchanged()
      Dim searchword As String = RichTextBox2.Text.ToString.Trim
  
      Dim index1 As Integer = 0
  
      While index1 &lt;&gt; -1
        If (index1 &lt; ORGFILETXT.Text.Length) Then
          index1 = ORGFILETXT.Find(searchword, index1, RichTextBoxFinds.None)
          'If (index1 &lt;= ORGFILETXT.TextLength) Then
              If index1 &lt;&gt; -1 Then
                  ORGFILETXT.SelectionStart = index1
                  ORGFILETXT.SelectionLength = searchword.Length
                  ORGFILETXT.SelectionColor = Color.Red
                  index1 = index1 + searchword.Length
              End If
          'End If
  
        Else
            index1 = -1
        End if
      End While
  End Sub
  </code></pre>
  
  <p>I searched word of datagridview1 rows and highlighted search word in rich text-box. text(it is having total text)
  I called this method in datagridview1 mouse click and key-up and key down event</p>
  
  <p>word is highlighted in rich text-box.text when I mouse click and key up and key down on datagridview1 rows of search word but some time getting full text is changed color how???
  pls help me</p>