How to Change the font color of the selected text in Rich text box control
Posted on August 22, 2009
Let's say you have Rich text box control in your form and you would like to change the font color of the selected text.
Instructions:
- Create a new Project
- Add a new form to it
- Add a Rich Text Box Control RichTextBox1 (To add Rich Text Box Control, you need to add the component using Project > Components and select Microsoft Rich Text Box Control 6.0)
- Add a command button Command1
- Add a Common Dialog Control CommonDialog1 (To add Common Dialog Control, you need to add the component using Project > Components and select Microsoft Common Dialog Control 6.0)
Now, goto form's code window and add the following code:
1 2 3 4 5 6 7 8 | Option Explicit Private Sub Command1_Click() 'Show the color dialog box CommonDialog1.ShowColor 'change the font color of the selected text to the color as selected in common dialog. RichTextBox1.SelColor = CommonDialog1.Color End Sub |