Control.DefaultFont-Eigenschaft

Ruft die Standardschriftart des Steuerelements ab.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

Syntax

'Declaration
Public Shared ReadOnly Property DefaultFont As Font
'Usage
Dim value As Font

value = Control.DefaultFont
public static Font DefaultFont { get; }
public:
static property Font^ DefaultFont {
    Font^ get ();
}
/** @property */
public static Font get_DefaultFont ()
public static function get DefaultFont () : Font

Eigenschaftenwert

Der Standard-Font des Steuerelements. Der zurückgegebene Wert variiert je nach Betriebssystem des Benutzers und lokaler Kultureinstellung des Systems.

Ausnahmen

Ausnahmetyp Bedingung

ArgumentException

Die Standardschriftart oder alternative regionale Schriftarten sind nicht auf dem Clientcomputer installiert.

Hinweise

In der folgenden Tabelle wird der von DefaultFont je nach Betriebssystem und lokaler Kultur zurückgegebene Wert beschrieben.

System und/oder Kultur

Schriftart

Windows NT 4x, japanische Version

MS UI Gothic, 9 pt.

Arabisch (Windows)

Tahoma, 8 pt.

Anderes Betriebssystem/andere Kultur

MS Shell Dlg, logische Schriftart, i. d. R. Microsoft Sans Serif 8 pt.

MS Shell Dlg wird einer in der Systemregistrierung festgelegten Schriftart zugeordnet.

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

Beispiel

Im folgenden Codebeispiel wird die Verwendung der Member DefaultBackColor, DefaultFont und DefaultForeColor veranschaulicht. Fügen Sie zum Ausführen des Beispiels den folgenden Code in ein Formular ein, das eine ListBox mit der Bezeichnung ListBox1 enthält. Rufen Sie die Populate_ListBox-Methode im Konstruktor oder in der Load-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.

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
// 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.
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.set_Dock(DockStyle.Bottom);
    // Display the values in the read-only properties 
    // DefaultBackColor, DefaultFont, DefaultForecolor.
    listBox1.get_Items().Add("Default BackColor: " 
        + ListBox.get_DefaultBackColor().ToString());
    listBox1.get_Items().Add("Default Font: " 
        + ListBox.get_DefaultFont().ToString());
    listBox1.get_Items().Add("Default ForeColor:" 
        + ListBox.get_DefaultForeColor().ToString());
} //Populate_ListBox

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

Siehe auch

Referenz

Control-Klasse
Control-Member
System.Windows.Forms-Namespace
Control.Font
Font