Quantcast
Channel: Windows Forms General forum
Viewing all articles
Browse latest Browse all 12583

RichTextBox: Why doesn't this code colorize added text?

$
0
0

Thanks for looking at this for me.

This is the code which is adding text:

rtbProcessing.Text = ""
        For Each rpi As RacePageInfo In RacePageURLs.Values
            If rpi.NumStr <> CurrentPageNumStr Then
                rtbProcessing.AppendText(rpi.NumStr & "  ")
            Else
                AddRedTextToRTB(rpi.NumStr & "(red)  ", rtbProcessing)
            End If
        Next

This is the AddRedTextToRTB routine:

Sub AddRedTextToRTB(ByRef str As String, ByRef rtb As RichTextBox)

        Dim start As Integer = rtb.TextLength
        rtb.AppendText(str)
        Dim strend As Integer = rtb.TextLength
        rtb.SelectionColor = Color.Red
        rtb.Select(start, strend - start)

    End Sub

Since I add "(red)" to all of the red code added I know that the login in the code which is adding the text is working right. But the color of all of the text in the box is black.

I'm sure it's my mistake but I sure can't see it.

Thanks,  Bob


Viewing all articles
Browse latest Browse all 12583

Trending Articles