Control.DefaultFont Control.DefaultFont Control.DefaultFont Control.DefaultFont Property

定義

取得控制項的預設字型。Gets the default font of the control.

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

屬性值

控制項的預設 FontThe default Font of the control. 所傳回的值將會根據使用者的作業系統和系統的本機文化特性設定而異。The value returned will vary depending on the user's operating system the local culture setting of their system.

例外狀況

用戶端電腦上未安裝預設字型或地區替代字型。The default font or the regional alternative fonts are not installed on the client computer.

範例

下列程式碼範例示範如何使用DefaultBackColorDefaultFontDefaultForeColor成員。The following code example demonstrates how to use the DefaultBackColor, DefaultFont, and DefaultForeColor members. 若要執行範例,請將下列程式碼貼入包含名為ListBox [ListBox1] 的表單中。To run the example, paste the following code in a form containing a ListBox called ListBox1. 在表單的函式或Load事件處理方法中呼叫方法。Populate_ListBoxCall the Populate_ListBox method in the form's constructor or Load event-handling method.

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

備註

下表描述DefaultFont根據作業系統和本機文化特性所傳回的值。The following table describes the value returned by DefaultFont depending on the operating system and local culture.

系統/和或文化特性System/and or Culture 字型Font
Windows NT 4x,日文版Windows NT 4x, Japanese version MS UI Mt,9點。MS UI Gothic, 9 point.
阿拉伯文 WindowsArabic Windows Tahoma,8點。Tahoma, 8 point.
其他作業系統/文化特性Other operating system/culture MS Shell Dlg 邏輯字型,通常是 Microsoft San Serif 8 點。MS Shell Dlg logical font, typically Microsoft San Serif 8 point.

MS Shell Dlg 會對應到系統登錄中的字型集。MS Shell Dlg maps to a font set in the system registry.

如果未安裝先前的字型,則預設字型為 Tahoma、8點。If the previous fonts are not installed, the default font is Tahoma, 8 point. 如果未安裝DefaultFont Tahoma、8點,則會傳回GenericSansSerif屬性的值。If Tahoma, 8 point, is not installed, DefaultFont returns the value of the GenericSansSerif property

適用於

另請參閱