Font.Style 属性

获取此 Font 的样式信息。

**命名空间:**System.Drawing
**程序集:**System.Drawing(在 system.drawing.dll 中)

语法

声明
Public ReadOnly Property Style As FontStyle
用法
Dim instance As Font
Dim value As FontStyle

value = instance.Style
public FontStyle Style { get; }
public:
property FontStyle Style {
    FontStyle get ();
}
/** @property */
public FontStyle get_Style ()
public function get Style () : FontStyle

属性值

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

示例

下面的代码示例演示如何使用 FontStyle 枚举将一个按钮的 Font 属性设置为新的粗体字体。此示例是针对使用 Windows 窗体而设计的。创建一个包含名为 Button1 的按钮的窗体,并将下面的代码粘贴到该窗体中。将 Button1_Click 方法与该按钮的 Click 事件关联。

 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
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:
   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(Object sender, System.EventArgs e)
{
    button1.set_Font(new Font(FontFamily.get_GenericSansSerif(), 12,
        FontStyle.Bold));
} //button1_Click

平台

Windows 98、Windows 2000 SP4、Windows CE、Windows Millennium Edition、Windows Mobile for Pocket PC、Windows Mobile for Smartphone、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

.NET Compact Framework

受以下版本支持:2.0、1.0

请参见

参考

Font 类
Font 成员
System.Drawing 命名空间