I'm trying to play around with rich text boxes at the moment, and appending information to it line by line, which seems to be working. But,
When a certain string comes through "xred", "xblk" I want the text colour to come through in a different colour.
the xred will come on a certain line and then from then on, it needs to append the text to the textbox in that colour, until the xblk string is read, when xblk is read, it needs to append everything in black until it hits the xred string.
At the moment, I have the following
Dim linecount As Integer = 0
Dim strreader As New StringReader(datastring)
Dim line As String
Do
linecount = linecount + 1
line = strreader.ReadLine()
If line.Contains("xred") Then
currenttb.ForeColor = Color.Red
End If
If line.Contains("xblk") Then
currenttb.ForeColor = Color.White
End If
currenttb.AppendText(line)
Loop Until linecount = 15
I do understand why it's not working. As I am telling the textbox to change colour on all text, rather than the line just read.
How can I set it so it appends lines in a different colour? At the moment, it seems to change the entire textbox forecolour to the last setting of the if statements.