How to set multiple FontStyles when instantiating a font?
In the Font constructor, you can combine multiple FontStyles using the OR operator:
Font font = new Font(this.Font, FontStyle.Bold | FontStyle.Underline);
The FontStyle
enum is a Flags
enum. This means that its members are all powers of two, allowing you to combine them using a binary OR.
For example, if you want bold and underline, you'd pass
FontStyle.Bold | FontStyle.Underline
The vertical bar (|
) is the binary OR operator.