Public Sub textcolorchanged()
Dim searchword As String = RichTextBox2.Text.ToString.Trim
Dim index1 As Integer = 0
While index1 <> -1
If (index1 < ORGFILETXT.Text.Length) Then
index1 = ORGFILETXT.Find(searchword, index1, RichTextBoxFinds.None)
'If (index1 <= ORGFILETXT.TextLength) Then
If index1 <> -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
我搜索了 datagridview1 行的单词并在富文本框中突出显示了搜索词。文本(它有全部文本)我在 datagridview1 鼠标单击和上键和下键事件中调用了这个方法
当我单击鼠标并在 datagridview1 行搜索词上向上和向下键时,单词在富文本框中突出显示。请帮助我