FontStyle FontStyle FontStyle FontStyle Enum

Definition

Specifies style information applied to text.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

public enum class FontStyle
[System.Flags]
public enum FontStyle
type FontStyle = 
Public Enum FontStyle
Inheritance
Attributes

Fields

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.

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.

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

Applies to