Control.DefaultFont 屬性

定義

取得控制項的預設字型。

C#
public static System.Drawing.Font DefaultFont { get; }

屬性值

控制項的預設 Font 。 所傳回的值將會根據使用者的作業系統和系統的本機文化特性設定而異。

例外狀況

用戶端電腦上未安裝預設字型或地區替代字型。

範例

下列程式碼範例示範如何使用 DefaultBackColorDefaultFontDefaultForeColor 成員。 若要執行此範例,請將下列程式碼貼到包含名為 ListBox1 的 ListBox 表單中。 Populate_ListBox在表單的建構函式或 Load 事件處理方法中呼叫 方法。

C#

// 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());
}

備註

下表描述根據作業系統和本機文化特性傳 DefaultFont 回的值。

系統/和或文化特性 字型
Windows NT 4x、日文版本 MS UI Gothic, 9 點。
阿拉伯文視窗 Tahoma,8 點。
其他作業系統/文化特性 MS Shell Dlg 邏輯字型,通常是 Microsoft San Serif 8 點。

MS Shell Dlg 會對應至系統登錄中的字型集。

如果未安裝先前的字型,預設字型為 Tahoma,8 點。 如果未安裝 8 點的 Tahoma, DefaultFont 則會傳回 屬性的值 GenericSansSerif

適用於

產品 版本
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

另請參閱