L
Lespaul36
I am writing lan chat program and want the messages to be color coded for
sent/recieved...you know the standard idea.
I cannot seem to get the richtextbox to keep the color. I do a recieve and
it is fine, I do a send and it is fine, another recieve and all of the text
becomes one color.
Here is the code I am using for the the Recieve..I use the same code for the
send.
Private Sub mobjClient_LineReceived(ByVal sender As Client, ByVal Data As
String) Handles mobjClient.LineReceived
Dim pstrmessage As String = Data
With txtRecieved
If .Text = "" Then
.Text &= pstrmessage
Else
.Text &= vbCrLf & pstrmessage
End If
Dim pintTextLen As Integer = Len(.Text)
Dim pintLoc As Integer = Len(.Text) - Len(pstrmessage)
Dim pintLen As Integer = Len(pstrmessage)
.SelectionStart = pintLoc
.SelectionLength = pintLen
Dim pstrSel As String = .SelectedText
.SelectionColor = Color.Navy
Me.Show()
End With
End Sub
I check the pstrSel and it looks like the corect text is selected, but the
selectioncolor seems to be changin everything. Am I just over looking
something here?
sent/recieved...you know the standard idea.
I cannot seem to get the richtextbox to keep the color. I do a recieve and
it is fine, I do a send and it is fine, another recieve and all of the text
becomes one color.
Here is the code I am using for the the Recieve..I use the same code for the
send.
Private Sub mobjClient_LineReceived(ByVal sender As Client, ByVal Data As
String) Handles mobjClient.LineReceived
Dim pstrmessage As String = Data
With txtRecieved
If .Text = "" Then
.Text &= pstrmessage
Else
.Text &= vbCrLf & pstrmessage
End If
Dim pintTextLen As Integer = Len(.Text)
Dim pintLoc As Integer = Len(.Text) - Len(pstrmessage)
Dim pintLen As Integer = Len(pstrmessage)
.SelectionStart = pintLoc
.SelectionLength = pintLen
Dim pstrSel As String = .SelectedText
.SelectionColor = Color.Navy
Me.Show()
End With
End Sub
I check the pstrSel and it looks like the corect text is selected, but the
selectioncolor seems to be changin everything. Am I just over looking
something here?