Font.Style Font.Style Font.Style Font.Style Property

定義

取得這個 Font 的樣式資訊。Gets style information for this Font.

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

屬性值

FontStyle 列舉,包含這個 Font 的樣式資訊。A FontStyle enumeration that contains style information for this Font.

範例

下列程式碼範例示範如何Font FontStyle使用列舉, 將按鈕的屬性設定為新的粗體字型。The following code example demonstrates how to set the Font property of a button to a new bold font using the FontStyle enumeration. 這個範例是設計來與 Windows Forms 搭配使用。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. 將方法與按鈕的Click事件產生關聯。 Button1_ClickAssociate the Button1_Click method with the button's Click event.

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

適用於