bueno mi problema es que estoy tratando de realizar un highlight de determinadas palabras en el richtextbox.
el codigo q cree, funciona, pero solo a medias. dado que por ejemplo si yo tengo q la palabra "#define" debe salir azul, al escribirla, sale azul, pero si yo borro "#" sigue azul. alguna idea de como podria resolver eso? y tambien q titila mientras escribo
aca dejo el codigo:
Public Sub HighLightText(ByVal Text As RichTextBox)
Dim oPos As Integer = Text.SelectionStart
If oPos > 0 Then
Dim Line As Integer = Text.GetLineFromCharIndex(Text.GetCharIndexFromPosition(Cursor.Position))
Dim pIni As Integer, pEnd As Integer, pos As Integer, word As String
pIni = Text.GetFirstCharIndexFromLine(Line)
pEnd = Text.Lines(Line).Length
For Each i As String In Words.Keys
pos = Text.Text.IndexOf(i, pIni, pEnd)
If ((Char.IsLetter(Chr(pos + 1)) Or Char.IsNumber(Chr(pos + 1))) And Words(i) <> Color.Blue) Or Not Char.IsLetter(Chr(pos + 1)) Then
If pos = 0 Then
word = i & " "
Else
word = i
End If
pos = Text.Text.IndexOf(word, pIni, pEnd)
If pos <> -1 Then
With Text
.SelectionStart = pos
.SelectionLength = i.Length
If .SelectionColor <> Words(i) Then .SelectionColor = Words(i)
End With
End If
End If
Next
End If
Text.SelectionStart = oPos
End Sub
Nota: la funcion es llamada en el callback TextChanged