语言

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

属性值

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

特性

示例

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

适用于