答案 0 :(得分:8)
FontStyle
是一个Flags
枚举。您通过或将它们组合在一起发送粗体和斜体:FontStyle.Bold | FontStyle.Italic
答案 1 :(得分:2)
尝试
FontStyle.Bold | FontStyle.Italic
(FontStyle用FlagsAttribute修饰,允许以这种方式组合选项)
答案 2 :(得分:1)
FontStyle
是Flags
枚举:
[FlagsAttribute]
public enum FontStyle
像
一样使用它x.FontStyle = FontStyle.Bold | FontStyle.Italic;
OR
Button1.Font = new Font(FontFamily.GenericSansSerif,
12.0F, FontStyle.Bold | FontStyle.Italic);
答案 3 :(得分:0)
这是一个位掩码枚举。要组合成员,请使用像这样的按位运算符(|):
label1.Font = new Font(label1.Font, FontStyle.Bold | FontStyle.Italic);
答案 4 :(得分:0)
FontStyle Enumeration使用FlagsAttribute,因此您可以使用按位运算符将多个FontStyles作为单个参数传递。
if (Button1.Font.Style != FontStyle.Bold || Button1.Font.Style != FontStyle.Italic)
Button1.Font = new Font(Button1.Font, FontStyle.Bold | FontStyle.Italic);