Control.DefaultFont 屬性

定義

取得控制項的預設字型。

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

屬性值

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

例外狀況

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

範例

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

// 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 回的值。

系統/和或文化特性 字型
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

適用於

另請參閱