Font.Style 属性

定义

获取此 Font 的样式信息。

public:
 property System::Drawing::FontStyle Style { System::Drawing::FontStyle get(); };
[System.ComponentModel.Browsable(false)]
public System.Drawing.FontStyle Style { get; }
[<System.ComponentModel.Browsable(false)>]
member this.Style : System.Drawing.FontStyle
Public ReadOnly Property Style As FontStyle

属性值

包含此 Font 的样式信息的 FontStyle 枚举。

属性

示例

下面的代码示例演示如何使用 FontStyle 枚举将按钮的 属性设置为Font新的粗体字体。 此示例旨在与 Windows 窗体 一起使用。 创建包含名为 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

适用于