Leer en inglés Editar

Compartir a través de


FontStyle Enum

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Specifies style information applied to text.

This enumeration supports a bitwise combination of its member values.

C#
[System.Flags]
public enum FontStyle
Inheritance
FontStyle
Attributes

Fields

Name Value Description
Regular 0

Normal text.

Bold 1

Bold text.

Italic 2

Italic text.

Underline 4

Underlined text.

Strikeout 8

Text with a line through the middle.

Examples

The following code example demonstrates how to set the Font property of a button to a new bold-style 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

Producto Versiones
.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