bold and italic

gpmaker

Member
Joined
Jun 3, 2004
Messages
24
hello again,

i'm working with a richtext box, i can get font to be bold, or italic, or underline.... but i can't get two or more at the same time.....
VB.NET:
text1.SelectionFont = New Font(text1.Font.Name, text1.Font.Size, FontStyle.bold)
i tried....
VB.NET:
text1.SelectionFont = New Font(text1.Font.Name, text1.Font.Size, FontStyle.bold and FontStyle.italic)

it marks no error, but a run time, it just makes the text regular. any ideas?
 
Hi GPMaker

You were very close to getting it. If you look up the
flagsattribute class, you will find that you CAN combine the styles, but with the OR keyword to accumulate bitwise keys:

"Bit fields can be combined using a bitwise OR operation, whereas enumerated constants cannot."

I tried out your example with just that and it works beautifully.

RichTextBox1.SelectionFont = New Font("ARIAL", 16, FontStyle.Italic Or FontStyle.Bold)

Happy programming.
 
Back
Top