font weights manipulation

This code toggles font inside a Richtextbox bold and normal. Assuming that the object is a picturebox..

'Bold
        If RichTextBox1.SelectionFont.Bold Then 'its already bold, so set it to regular
            RichTextBox1.SelectionFont = New Font(RichTextBox1.Font.FontFamily, RichTextBox1.Font.Size, FontStyle.Regular)
        Else 'make it bold
            RichTextBox1.SelectionFont = New Font(RichTextBox1.Font.FontFamily, RichTextBox1.Font.Size, FontStyle.Bold)
        End If

however; If Id like to add  an underline on it. How the code be adjusted
zachvaldezAsked:
Who is Participating?
 
Bob LearnedConnect With a Mentor Commented:
Your code would look like this:

RichTextBox1.SelectionFont = New Font(RichTextBox1.Font.FontFamily, RichTextBox1.Font.Size, FontStyle.Bold Or FontStyle.Underline)
0
 
Bob LearnedCommented:
Assuming this is a Windows Forms RichTextBox, that would be:

FontStyle.Bold Or FontStyle.Underline

The FontStyle enumeration has the Flags attribute, which means that you can combine any of the effects by "or-ing" them together.
0
 
zachvaldezAuthor Commented:
Hi where will the code go thanks. or willit be another option line of code?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.