Link to home
Start Free TrialLog in
Avatar of H-SC
H-SCFlag for United States of America

asked on

Change font color in richtextbox only for selected string

I have a richtextbox on a form with a button that brings up a colordialog.  Currently if I use this method when I choose a color it changes everything in the richtextbox to that particular color.
here is what I would like ...
I would like to be able to highlight or select text and change the color only for the selected string.

Thanks in advance.
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Try this:

        Me.RichTextBox1.SelectionStart = 50
        Me.RichTextBox1.SelectionLength = 10
        Me.RichTextBox1.SelectionColor = Color.Red

Bob
Avatar of H-SC

ASKER

Bob,

Do I put this code on the button click?
ASKER CERTIFIED SOLUTION
Avatar of Mike Tomlinson
Mike Tomlinson
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of H-SC

ASKER

Idle Mind,

That worked great !