为什么 C# 中的 fontstyle 枚举缺少粗体斜体?

发布于 2024-12-29 07:53:01 字数 245 浏览 6 评论 0原文

可能的重复:
c# 使字体变为斜体和粗体

我如何设置字体样式字体改为粗体斜体?

我无法将字体的字体样式设置为粗体斜体..在哪里以及如何设置它>?

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 >?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

山人契 2025-01-05 07:53:01

FontStyle 是一个 Flags 枚举。您可以通过将粗体和斜体组合在一起来发送粗体和斜体: FontStyle.Bold |字体样式.斜体

FontStyle is a Flags enumeration. You send bold and italic by or'ing them together: FontStyle.Bold | FontStyle.Italic

拥抱没勇气 2025-01-05 07:53:01

尝试

FontStyle.Bold | FontStyle.Italic

(FontStyle 用 FlagsAttribute 装饰,允许以这种方式组合选项)

Try

FontStyle.Bold | FontStyle.Italic

(FontStyle is decorated with FlagsAttribute which allows combining options this way)

习ぎ惯性依靠 2025-01-05 07:53:01

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);

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);
农村范ル 2025-01-05 07:53:01

它是一个位掩码枚举。要组合成员,请使用按位 OR 运算符 (|),如下所示:

label1.Font = new Font(label1.Font, FontStyle.Bold | FontStyle.Italic);

另请参阅使用C# 中的位掩码

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#

再可℃爱ぅ一点好了 2025-01-05 07:53:01

FontStyle 枚举使用 FlagsAttribute 因此,您可以使用按位运算符将多个 FontStyle 作为传递单一参数。

if (Button1.Font.Style != FontStyle.Bold || Button1.Font.Style != FontStyle.Italic)
            Button1.Font = new Font(Button1.Font, FontStyle.Bold | FontStyle.Italic);

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文