How I can write in a RichTextBox using multiple font color?
Thanks,
AA.Keynia
Printable View
How I can write in a RichTextBox using multiple font color?
Thanks,
AA.Keynia
The SelColor property.
Hi,
If you want to change the color of the text in Rich Text Box, first select the text to be changed and use selcolor property. I have added a sample vb code.
Place a richtextbox and change the name property to rt.
Load a text file with word Start# and End#.
The following code will change the contents in between Start# and End# to red color.
Private Sub Form_Load()
startpos = 0
Do While Not flag
rt.SelLength = 0
startpos = rt.Find("START#", startpos)
If startpos = -1 Then flag = True
startpos = startpos + rt.SelLength
rt.SelLength = 0
endpos = rt.Find("END#", startpos)
If endpos = -1 Then flag = True
If Not flag Then
rt.SelStart = startpos
rt.SelLength = endpos - startpos
rt.SelColor = vbRed
End If
startpos = endpos
Loop
End Sub
I hope this code also will help you.
Bye
A. Karthikeyan