FontStyle 枚举


指定应用到文本的字形信息。Specifies style information applied to text.

此枚举有一个 FlagsAttribute 属性,允许按位组合成员值。

public enum class FontStyle
public enum FontStyle
type FontStyle = 
Public Enum FontStyle


Bold 1

加粗文本。Bold text.

Italic 2

斜体文本。Italic text.

Regular 0

普通文本。Normal text.

Strikeout 8

中间有直线通过的文本。Text with a line through the middle.

Underline 4

带下划线的文本。Underlined text.


下面的代码示例演示如何使用 FontStyle 枚举将按钮的 Font 属性设置为新的粗体样式字体。The following code example demonstrates how to set the Font property of a button to a new bold-style font using the FontStyle enumeration. 此示例旨在与 Windows 窗体一起使用。This example is designed to be used with Windows Forms. 创建一个包含名为 Button1 的按钮的窗体,并将以下代码粘贴到其中。Create a form containing a button named Button1 and paste the following code into it. Button1_Click 方法与按钮的 Click 事件关联。Associate the Button1_Click method with the button's Click event.

   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