使用英语阅读

通过


FontStyle 枚举

定义

指定应用到文本的字形信息。

此枚举支持其成员值的按位组合。

public enum class FontStyle
[System.Flags]
public enum FontStyle
[<System.Flags>]
type FontStyle = 
Public Enum FontStyle
继承
FontStyle
属性

字段

名称 说明
Bold 1

加粗文本。

Italic 2

倾斜文本。

Regular 0

普通文本。

Strikeout 8

中间有直线通过的文本。

Underline 4

带下划线的文本。

示例

下面的代码示例演示如何使用 FontStyle 枚举将按钮的 属性设置为Font新的粗体字体。 此示例旨在与 Windows 窗体 一起使用。 Create包含名为 Button1 的按钮的窗体,并将以下代码粘贴到其中。 将 Button1_Click 方法与按钮的 Click 事件相关联。

private:
   void Button1_Click( System::Object^ /*sender*/, System::EventArgs^ /*e*/ )
   {
      Button1->Font = gcnew System::Drawing::Font( FontFamily::GenericSansSerif,12.0F,FontStyle::Bold );
   }
private void Button1_Click(System.Object sender, System.EventArgs e)
{
    if (Button1.Font.Style != FontStyle.Bold)
            Button1.Font = new Font(FontFamily.GenericSansSerif,
            12.0F, FontStyle.Bold);
}
 Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
    If Not Button1.Font.Style = FontStyle.Bold Then
        Button1.Font = New Font(FontFamily.GenericSansSerif, _
            12.0F, FontStyle.Bold)
    End If
End Sub

适用于

产品 版本
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9