Foros del Web » Programación para mayores de 30 ;) » .NET »

richtextbox con linea de cada color

Estas en el tema de richtextbox con linea de cada color en el foro de .NET en Foros del Web. Quiero hacer un richtextbox con una linea de cada color. Tengo este código: Public Class Form1 Dim UltimaPosicion As Integer = 0 Private Sub Button1_Click(ByVal ...
  #1 (permalink)  
Antiguo 26/03/2009, 16:22
 
Fecha de Ingreso: enero-2008
Mensajes: 229
Antigüedad: 16 años, 3 meses
Puntos: 0
richtextbox con linea de cada color

Quiero hacer un richtextbox con una linea de cada color. Tengo este código:

Public Class Form1
Dim UltimaPosicion As Integer = 0
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

With RichTextBox1
.Text &= "AAAA" & vbNewLine
.SelectionStart = UltimaPosicion
.SelectionLength = .TextLength
.SelectionFont = New Font(.SelectionFont.FontFamily, .SelectionFont.Size, FontStyle.Regular)
.SelectionColor = Color.Red
'.SelectionStart = .SelectionStart + .SelectionLength
.Refresh()
UltimaPosicion = .SelectionStart + .SelectionLength
End With
End Sub

Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click

With RichTextBox1
.Text &= "BBBB" & vbNewLine
.SelectionStart = UltimaPosicion
.SelectionLength = .TextLength
.SelectionFont = New Font(.SelectionFont.FontFamily, .SelectionFont.Size, FontStyle.Regular)
.SelectionColor = Color.Blue
'.SelectionStart = .SelectionStart + .SelectionLength
.Refresh()
UltimaPosicion = .SelectionStart + .SelectionLength
End With
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
UltimaPosicion = 0
RichTextBox1.Text = String.Empty
End Sub
End Class

Pero al tercer intento no hace lo correcto... pone las tres lineas en el color que has empezado. Alguien sabe pq.?
Asias
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 19:39.