Control.DefaultFont Właściwość

Definicja

Pobiera domyślną czcionkę kontrolki.

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

Wartość właściwości

Wartość domyślna Font kontrolki. Zwrócona wartość będzie się różnić w zależności od systemu operacyjnego użytkownika ustawienia kultury lokalnej systemu.

Wyjątki

Czcionka domyślna lub regionalne alternatywne czcionki nie są zainstalowane na komputerze klienckim.

Przykłady

W poniższym przykładzie kodu pokazano, jak używać DefaultBackColorelementów członkowskich , DefaultFonti DefaultForeColor . Aby uruchomić przykład, wklej następujący kod w formularzu zawierającym ListBox nazwę ListBox1. Wywołaj metodę Populate_ListBox w metodzie konstruktora formularza lub Load metody obsługi zdarzeń.

// 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

Uwagi

W poniższej tabeli opisano wartość zwracaną w DefaultFont zależności od systemu operacyjnego i kultury lokalnej.

System/i lub kultura Czcionka
Windows NT 4x, wersja japońska MS UI Gothic, 9 punktów.
Arabski system Windows Tahoma, 8 punktów.
Inny system operacyjny/kultura Czcionka logiczna MS Shell Dlg, zazwyczaj Microsoft San Serif 8 punkt.

Ms Shell Dlg mapuje czcionkę na zestaw czcionek w rejestrze systemowym.

Jeśli poprzednie czcionki nie są zainstalowane, domyślną czcionką jest Tahoma, 8 punktów. Jeśli tahoma, 8 punktów, nie jest zainstalowany, DefaultFont zwraca wartość GenericSansSerif właściwości

Dotyczy

Zobacz też