Possible Duplicate:
c# Make font italic and bold
How do i set the font style of a font to bold italic?
I am unable to set the fontstyle of font to bold italic.. where and how can i set it >?
Possible Duplicate:
c# Make font italic and bold
How do i set the font style of a font to bold italic?
I am unable to set the fontstyle of font to bold italic.. where and how can i set it >?
Try
FontStyle.Bold | FontStyle.Italic
(FontStyle is decorated with FlagsAttribute which allows combining options this way)
The FontStyle
is a Flags
enum:
[FlagsAttribute]
public enum FontStyle
use it like
x.FontStyle = FontStyle.Bold | FontStyle.Italic;
OR
Button1.Font = new Font(FontFamily.GenericSansSerif,
12.0F, FontStyle.Bold | FontStyle.Italic);
It is a bitmask enumeration. To combine members use the bit-wise OR operator (|) like this:
label1.Font = new Font(label1.Font, FontStyle.Bold | FontStyle.Italic);
See also Using a bitmask in C#
The FontStyle Enumeration uses the FlagsAttribute thus you can use bitwise operators to pass multiple FontStyles as a single parameter.
if (Button1.Font.Style != FontStyle.Bold || Button1.Font.Style != FontStyle.Italic)
Button1.Font = new Font(Button1.Font, FontStyle.Bold | FontStyle.Italic);