Share via


Control.DefaultFont Properti

Definisi

Mendapatkan font default kontrol.

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

Nilai Properti

Default Font kontrol. Nilai yang dikembalikan akan bervariasi tergantung pada sistem operasi pengguna pengaturan budaya lokal sistem mereka.

Pengecualian

Fonta default atau font alternatif regional tidak diinstal pada komputer klien.

Contoh

Contoh kode berikut menunjukkan cara menggunakan DefaultBackColoranggota , , DefaultFontdan DefaultForeColor . Untuk menjalankan contoh, tempelkan kode berikut dalam formulir yang berisi yang ListBox disebut ListBox1. Populate_ListBox Panggil metode dalam metode konstruktor atau Load penanganan peristiwa formulir.

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

Keterangan

Tabel berikut ini menjelaskan nilai yang dikembalikan tergantung DefaultFont pada sistem operasi dan budaya lokal.

Sistem/dan atau Budaya Font
Windows NT 4x, versi Jepang MS UI Gothic, 9 poin.
Jendela Arab Tahoma, 8 poin.
Sistem operasi/budaya lainnya Font logis MS Shell Dlg, biasanya poin Microsoft San Serif 8.

MS Shell Dlg memetakan ke font yang diatur dalam registri sistem.

Jika font sebelumnya tidak diinstal, font defaultnya adalah Tahoma, 8 poin. Jika Tahoma, 8 poin, tidak diinstal, DefaultFont mengembalikan nilai GenericSansSerif properti

Berlaku untuk

Lihat juga