Freigeben über


Control.DefaultFont Eigenschaft

Definition

Ruft die Standardschriftart des Steuerelements ab.

public:
 static property System::Drawing::Font ^ DefaultFont { System::Drawing::Font ^ get(); };
public static System.Drawing.Font DefaultFont { get; }
static member DefaultFont : System.Drawing.Font
Public Shared ReadOnly Property DefaultFont As Font

Eigenschaftswert

Der Standardwert Font des Steuerelements. Der zurückgegebene Wert variiert je nach Betriebssystem des Benutzers in der lokalen Kultureinstellung seines Systems.

Ausnahmen

Die Standardschriftart oder die regionalen alternativen Schriftarten sind nicht auf dem Clientcomputer installiert.

Beispiele

Im folgenden Codebeispiel wird veranschaulicht, wie die DefaultBackColorElemente und DefaultForeColor die Elemente DefaultFontverwendet werden. Zum Ausführen des Beispiels fügen Sie den folgenden Code in ein Formular mit dem ListBox Namen ListBox1 ein. Rufen Sie die Methode im Konstruktor oder Load in der Populate_ListBox Ereignisbehandlungsmethode des Formulars auf.

// The following method displays the default font, 
// background color and foreground color values for the ListBox  
// control. The values are displayed in the ListBox, itself.
void Populate_ListBox()
{
   ListBox1->Dock = DockStyle::Bottom;
   
   // Display the values in the read-only properties 
   // DefaultBackColor, DefaultFont, DefaultForecolor.
   ListBox1->Items->Add( String::Format( "Default BackColor: {0}", ListBox::DefaultBackColor ) );
   ListBox1->Items->Add( String::Format( "Default Font: {0}", ListBox::DefaultFont ) );
   ListBox1->Items->Add( String::Format( "Default ForeColor:{0}", ListBox::DefaultForeColor ) );
}

// The following method displays the default font, 
// background color and foreground color values for the ListBox  
// control. The values are displayed in the ListBox, itself.

private void Populate_ListBox()
{
    ListBox1.Dock = DockStyle.Bottom;

    // Display the values in the read-only properties 
    // DefaultBackColor, DefaultFont, DefaultForecolor.
    ListBox1.Items.Add("Default BackColor: " + 
        ListBox.DefaultBackColor.ToString());
    ListBox1.Items.Add("Default Font: " + 
        ListBox.DefaultFont.ToString());
    ListBox1.Items.Add("Default ForeColor:" + 
        ListBox.DefaultForeColor.ToString());
}

' The following method displays the default font, 
' background color and foreground color values for the ListBox  
' control. The values are displayed in the ListBox, itself.

Private Sub Populate_ListBox()
    ListBox1.Dock = DockStyle.Bottom

    ' Display the values in the read-only properties 
    ' DefaultBackColor, DefaultFont, DefaultForecolor.
    ListBox1.Items.Add("Default BackColor: " & ListBox.DefaultBackColor.ToString)
    ListBox1.Items.Add("Default Font: " & ListBox.DefaultFont.ToString)
    ListBox1.Items.Add("Default ForeColor:" & ListBox.DefaultForeColor.ToString)

End Sub

Hinweise

In der folgenden Tabelle wird der von dem Betriebssystem und der lokalen Kultur zurückgegebene DefaultFont Wert beschrieben.

System/und Kultur Schriftart
Windows NT 4x, japanische Version MS UI Gothic, 9 Punkt.
Arabisches Windows Tahoma, 8 Punkt.
Andere Betriebssysteme/Kultur LOGISCHE SCHRIFTART MS Shell Dlg, in der Regel Microsoft San Serif 8 Punkt.

MS Shell Dlg ordnet eine Schriftart in der Systemregistrierung zu.

Wenn die vorherigen Schriftarten nicht installiert sind, lautet die Standardschriftart Tahoma, 8 Punkt. Wenn Tahoma, 8 Punkt, nicht installiert ist, DefaultFont gibt den Wert der GenericSansSerif Eigenschaft zurück.

Gilt für:

Weitere Informationen