Прочетете на английски Редактиране

Споделяне чрез


Font.Style Property

Definition

Gets style information for this Font.

C#
[System.ComponentModel.Browsable(false)]
public System.Drawing.FontStyle Style { get; }

Property Value

A FontStyle enumeration that contains style information for this Font.

Attributes

Examples

The following code example demonstrates how to set the Font property of a button to a new bold font using the FontStyle enumeration. This example is designed to be used with Windows Forms. Create a form containing a button named Button1 and paste the following code into it. Associate the Button1_Click method with the button's Click event.

C#
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);
}

Applies to

Продукт Версии
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 2.0 (package-provided)
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10