FontFamily.IsStyleAvailable(FontStyle) Methode

Definition

Gibt an, ob die angegebene FontStyle Enumeration verfügbar ist.

public:
 bool IsStyleAvailable(System::Drawing::FontStyle style);
public bool IsStyleAvailable (System.Drawing.FontStyle style);
member this.IsStyleAvailable : System.Drawing.FontStyle -> bool
Public Function IsStyleAvailable (style As FontStyle) As Boolean

Parameter

style
FontStyle

Das zu testende FontStyle.

Gibt zurück

true, wenn die angegebene FontStyle verfügbar ist; andernfalls false.

Beispiele

Das folgende Codebeispiel wurde für die Verwendung mit Windows Forms entwickelt und erfordert PaintEventArgse, bei dem es sich um einen Parameter des Paint-Ereignishandlers handelt. Der Code führt die folgenden Aktionen aus:

  • Erstellt eine FontFamily.

  • Testet, ob die Schriftfamilie kursiv formatiert ist.

  • Wenn dies der Grund ist, zeichnet Sie Text auf den Bildschirm.

public:
   void IsStyleAvailable_Example( PaintEventArgs^ e )
   {
      // Create a FontFamily object.
      FontFamily^ myFontFamily = gcnew FontFamily( "Arial" );

      // Test whether myFontFamily is available in Italic.
      if ( myFontFamily->IsStyleAvailable( FontStyle::Italic ) )
      {
         // Create a Font object using myFontFamily.
         System::Drawing::Font^ familyFont = gcnew System::Drawing::Font( myFontFamily,16,FontStyle::Italic );

         // Use familyFont to draw text to the screen.
         e->Graphics->DrawString( myFontFamily->Name + " is available in Italic",
               familyFont, Brushes::Black, PointF(0,0) );
      }
   }
public void IsStyleAvailable_Example(PaintEventArgs e)
{
    // Create a FontFamily object.
    FontFamily myFontFamily = new FontFamily("Arial");
             
    // Test whether myFontFamily is available in Italic.
    if(myFontFamily.IsStyleAvailable(FontStyle.Italic))
    {
             
        // Create a Font object using myFontFamily.
        Font familyFont = new Font(myFontFamily, 16, FontStyle.Italic);
             
        // Use familyFont to draw text to the screen.
        e.Graphics.DrawString(
            myFontFamily.Name + " is available in Italic",
            familyFont,
            Brushes.Black,
            new PointF(0, 0));
    }
}
Public Sub IsStyleAvailable_Example(ByVal e As PaintEventArgs)

    ' Create a FontFamily object.
    Dim myFontFamily As New FontFamily("Arial")

    ' Test whether myFontFamily is available in Italic.
    If myFontFamily.IsStyleAvailable(FontStyle.Italic) Then

        ' Create a Font object using myFontFamily.
        Dim familyFont As New Font(myFontFamily, 16, FontStyle.Italic)

        ' Use familyFont to draw text to the screen.
        e.Graphics.DrawString(myFontFamily.Name & _
        " is available in Italic", familyFont, Brushes.Black, _
        New PointF(0, 0))
    End If
End Sub

Gilt für: