Printing in bold and italics at the same time

J Trahair

Well-known member
Joined
May 14, 2008
Messages
175
Location
Spain
Programming Experience
10+
I am using
HTML:
ev.Graphics.DrawString("String", fntPrintFont, Brushes.Black, 12, numYPos), New StringFormat())
to print stuff to a printer.
I have previously set
HTML:
fntPrintFont = New Font("Arial", 12, FontStyle.Italic)
to get the string in italics.
How do I get the string to print in Bold AND Italic? I tried
HTML:
fntPrintFont = New Font("Arial", 12, FontStyle.Bold + FontStyle.Italic)
and
HTML:
fntPrintFont = New Font("Arial", 12, FontStyle.Bold, FontStyle.Italic)
but VB doesn't like that.
How may I combine two printing attributes?

Thank you.
 
VB.NET:
fntPrintFont = New Font("Arial", 12, FontStyle.Bold Or FontStyle.Italic)
 
FontStyle is a flags enumeration, which members you can do bitwise operations with. 'Or' is the bitwise operation to combine those two flags. They are also called logical operators.

If you look in help for FontStyle enumeration it says this:
This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.
If you look further in help about 'bitwise' you can find this article: Logical and Bitwise Operators in Visual Basic
 
Back
Top