FontStyle FontStyle FontStyle FontStyle Enum

定義

指定要套用至文字的樣式資訊。Specifies style information applied to text.

此列舉具有 FlagsAttribute 個屬性允許以位元方式合併其成員值。

public enum class FontStyle
[System.Flags]
public enum FontStyle
type FontStyle = 
Public Enum FontStyle
繼承
屬性

欄位

Bold Bold Bold Bold 1

粗體文字。Bold text.

Italic Italic Italic Italic 2

斜體文字。Italic text.

Regular Regular Regular Regular 0

一般文字。Normal text.

Strikeout Strikeout Strikeout Strikeout 8

中間有線條經過的文字。Text with a line through the middle.

Underline Underline Underline Underline 4

加上底線的文字。Underlined text.

範例

下列程式碼範例示範如何Font FontStyle使用列舉, 將按鈕的屬性設定為新的粗體樣式字型。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 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

適用於