Visual Basic.NET - Ayuda con cambio de color de texto en richtextbox

 
Vista:

Ayuda con cambio de color de texto en richtextbox

Publicado por Oscar (1 intervención) el 20/08/2005 19:21:28
Hola a todos:
Quisiera saber si me pueden ayudar con un problemilla que tengo con un ritchtextbox, lo que busco es saber como puedo cambiar el color de la letra en un richtextbox, teniendo en cuenta que los numeros son de un color y las letras de otro, ayuda urgente, lo que llevo es lo siguiente:

Dim archivo As New OpenFileDialog
Dim i As Integer
archivo.FileName = "D:\*.txt"
archivo.ShowDialog()
r1.LoadFile(archivo.FileName, RichTextBoxStreamType.PlainText)
Dim vector() As String
Dim separador(3) As Char
separador.SetValue(Chr(32), 0)
separador.SetValue(Chr(10), 1)
separador.SetValue(Chr(12), 2)
vector = r1.Text.Split(separador)
For i = 0 To vector.Length - 1
If IsNumeric(vector.GetValue(i)) Then
L1.Items.Add(vector.GetValue(i))
Else
L2.Items.Add(vector.GetValue(i))
End If
Next i

Dim lugar As String
For i = 0 To R1.Text.Length - 1
MsgBox(vector.GetValue(i))
If Not IsNumeric(vector.GetValue(i)) Then
lugar = R1.Find(vector.GetValue(i))
'R1.Select(lugar, L1.Items.Item(i))
R1.SelectionColor = System.Drawing.Color.Red
Else
lugar = R1.Find(vector.GetValue(i))
'R1.Select(lugar, L1.Items.Item(i))
R1.SelectionColor = System.Drawing.Color.Purple
If EOF(R1.Text) Then
Exit For
End If
End If
Next i

ese es todo el programa, le agradesco de ante mano
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Ayuda con cambio de color de texto en richtextb

Publicado por hixem (178 intervenciones) el 23/08/2005 12:52:00
Hola, lo que se me ocurre es lo siguiente:
Añade a tu formulario un "fontdialog" (llamalo fontdialog1) desde el cuadro de herramientas y crea algo como esto:

Private Sub FormatFont_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FormatFont.Click
If Not editor.SelectionFont Is Nothing Then
FontDialog1.Font = editor.SelectionFont
Else
FontDialog1.Font = Nothing
End If
FontDialog1.ShowApply = True
If FontDialog1.ShowDialog() = DialogResult.OK Then
editor.SelectionFont = FontDialog1.Font
End If
End Sub

Selecciona el texto y aqui puedes jugar con el color la fuente etc
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar