Monday, May 13, 2013

Multicolor RichTextBox


RichTextBox1.Text = "This is black "
        ' Move the insertion point to the end of the line
        RichTextBox1.Select(RichTextBox1.TextLength, 0)
        ' Set the formatting and insert the second snippet of text
        RichTextBox1.SelectionFont = New Font(RichTextBox1.Font, FontStyle.Bold)
        RichTextBox1.SelectionColor = Color.Green
        RichTextBox1.AppendText("BOLD GREEN")
        '' Revert the formatting back to the defaults, and add the third snippet of text
        RichTextBox1.SelectionFont = RichTextBox1.Font
        RichTextBox1.SelectionColor = RichTextBox1.ForeColor
        RichTextBox1.AppendText(" black again")