PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197

PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
font style is bold+underline-VBForums
Results 1 to 4 of 4

Thread: font style is bold+underline

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2007
    Posts
    44

    font style is bold+underline

    hi
    I have a richtextbox and i want to make some text to be bold + underline.
    how can i combine both styles

    thanks

  2. #2
    Raging swede Atheist's Avatar
    Join Date
    Aug 2005
    Location
    Sweden
    Posts
    8,020

    Re: font style is bold+underline

    Set its fontstyle to FontStyle.Bold Xor FontStyle.Underline
    Rate posts that helped you. I do not reply to PM's with coding questions.
    How to Get Your Questions Answered
    Current project: tunaOS
    Me on.. BitBucket, Google Code, Github (pretty empty)

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    23,145

    Re: font style is bold+underline

    vb Code:
    1. RichTextBox1.SelectionFont = New Font(RichTextBox1.SelectionFont.Name, RichTextBox1.SelectionFont.Size, FontStyle.Bold Or FontStyle.Underline)

  4. #4
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    104,741

    Re: font style is bold+underline

    I'm afraid neither suggestion so far is quite right. To apply a style to a Font without losing any current styles you need to perform a bitwise Or with the current style and the new style. That means your code should be:
    vb.net Code:
    1. myRichTextBox.SelectionFont = New Font(myRichTextBox.SelectionFont, myRichTextBox.SelectionFont.Style Or FontStyle.Bold Or FontStyle.Underline
    That will create a new Font using the existing Font as a basis and set its Style to a combination of the current style, Bold and Underline. By including the current Style in the combination you will not lose any other styles that are currently applied. If you set the style using Bold and Underline only then you would lose any other styles.

    Having said that, if you actually DO want to lose any other styles then you would not include the current style in the combination.

    I should also point out that you'd only use Xor when toggling an existing style. For instance, this code:
    vb.net Code:
    1. myRichTextBox.SelectionFont = New Font(myRichTextBox.SelectionFont, myRichTextBox.SelectionFont.Style Xor FontStyle.Bold
    will turn Bold on if it's currently off and it will turn it off if it's currently on.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width