Avatar of zachvaldez
zachvaldezFlag for United States of America asked on

font weights manipulation

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

        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
Visual Basic.NET

Avatar of undefined
Last Comment
Bob Learned

8/22/2022 - Mon
Bob Learned

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.

Hi where will the code go thanks. or willit be another option line of code?
Bob Learned

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Your help has saved me hundreds of hours of internet surfing.