Control.DefaultFont 属性

定义

获取控件的默认字体。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

属性值

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. 若要运行该示例,请将以下代码粘贴到包含名为 ListBox1 的的窗体中 ListBoxTo run the example, paste the following code in a form containing a ListBox called ListBox1. Populate_ListBox在窗体的构造函数或 Load 事件处理方法中调用方法。Call 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 哥特,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. 如果未安装 Tahoma、8点,则 DefaultFont 返回属性的值 GenericSansSerifIf Tahoma, 8 point, is not installed, DefaultFont returns the value of the GenericSansSerif property

适用于

另请参阅