Control.DefaultForeColor 屬性

定義

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

public:
 static property System::Drawing::Color DefaultForeColor { System::Drawing::Color get(); };
public static System.Drawing.Color DefaultForeColor { get; }
static member DefaultForeColor : System.Drawing.Color
Public Shared ReadOnly Property DefaultForeColor As Color

屬性值

控制項的預設前景 Color。 預設值為 ControlText

範例

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

備註

這是非父系控制項的預設 ForeColor 屬性值。 衍生類別可以有不同的預設值。

適用於

另請參閱