Control.DefaultBackColor 屬性

定義

取得控制項的預設背景色彩。

C#
public static System.Drawing.Color DefaultBackColor { get; }

屬性值

控制項的預設背景 Color。 預設值為 Control

範例

下列程式碼範例示範如何使用 DefaultBackColorDefaultFontDefaultForeColor 成員。 若要執行此範例,請將下列程式碼貼到包含 ListBox 名為 ListBox1 的表單中。 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());
}

備註

這是泛型最上層控制項的預設 BackColor 屬性值。 衍生類別可以有不同的預設值。

適用於

產品 版本
.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

另請參閱