【发布时间】:2012-01-27 04:03:05
【问题描述】:
【问题讨论】:
-
System.Drawing.Font? WPF 字体?
-
问重复的问题...仍然得到 5 个正确答案...不接受任何一个。
【问题讨论】:
FontStyle 是一个Flags 枚举。您可以通过将它们组合在一起来发送粗体和斜体:FontStyle.Bold | FontStyle.Italic
【讨论】:
试试
FontStyle.Bold | FontStyle.Italic
(FontStyle 用 FlagsAttribute 装饰,允许以这种方式组合选项)
【讨论】:
FontStyle 是一个 Flags 枚举:
[FlagsAttribute]
public enum FontStyle
像这样使用它
x.FontStyle = FontStyle.Bold | FontStyle.Italic;
或
Button1.Font = new Font(FontFamily.GenericSansSerif,
12.0F, FontStyle.Bold | FontStyle.Italic);
【讨论】:
这是一个位掩码枚举。要组合成员,请使用按位 OR 运算符 (|),如下所示:
label1.Font = new Font(label1.Font, FontStyle.Bold | FontStyle.Italic);
【讨论】:
FontStyle 枚举使用FlagsAttribute,因此您可以使用按位运算符将多个 FontStyles 作为单个参数传递。
if (Button1.Font.Style != FontStyle.Bold || Button1.Font.Style != FontStyle.Italic)
Button1.Font = new Font(Button1.Font, FontStyle.Bold | FontStyle.Italic);
【讨论】: