05-25-2012, 11:47 PM
I agree here is how to do it in a richtext box if you do decide to go ahead and do so
add 1 textbox
add 1 Button
add 1 Richtextbox
Code
I could not find a way either hope this helps in some way
Kind Regards
Bradley
add 1 textbox
add 1 Button
add 1 Richtextbox
Code
Code:
Public Class Form1
Sub findTextAndHighlight(ByVal searchtext As String, ByVal rtb As RichTextBox)
Dim textEnd As Integer = rtb.TextLength
Dim index As Integer = 0
Dim fnt As Font = New Font(rtb.Font, FontStyle.Bold)
Dim lastIndex As Integer = rtb.Text.LastIndexOf(searchtext)
While (index < lastIndex)
rtb.Find(searchtext, index, textEnd,
RichTextBoxFinds.WholeWord)
rtb.SelectionFont = fnt
rtb.SelectionLength = searchtext.Length
rtb.SelectionColor = Color.Black
rtb.SelectionBackColor = Color.Yellow
index = rtb.Text.IndexOf(searchtext, index) + 1
End While
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
findTextAndHighlight(TextBox1.Text, RichTextBox1)
End Sub
End Class
I could not find a way either hope this helps in some way
Kind Regards
Bradley