Multiple Colored Texts in RichTextBox using VB.Net
Actually This Application tells how to enter values in a richtextbox with multiple color texts. There is a property to set colored text by using SelectionText. Richtextbox has the properties of SelectionFont, SelectionColor and SelectedText. Setting the values for these properties makes multiple colors in our richtextbox. I just tried to create it as a sample application and it is done.
.vb Code
Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Linq
Imports System.Text
Imports System.Windows.Forms
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button1.Click
Dim font As New Font("Tahoma", 8, FontStyle.Regular)
RichTextBox1.SelectionFont = font
RichTextBox1.SelectionColor = Color.Red
RichTextBox1.SelectedText = Environment.NewLine + textBox1.Text
End Sub
Private Sub Button2_Click(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles Button2.Click
Dim font As New Font("Tahoma", 8, FontStyle.Regular)
RichTextBox1.SelectionFont = font
RichTextBox1.SelectionColor = Color.Green
RichTextBox1.SelectedText = Environment.NewLine + textBox1.Text
End Sub
End Class