Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
DefaultForeColor Property
Collapse the table of content
Expand the table of content

Control.DefaultForeColor Property

Gets the default foreground color of the control.

[Visual Basic]
Public Shared ReadOnly Property DefaultForeColor As Color
[C#]
public static Color DefaultForeColor {get;}
[C++]
public: __property static Color get_DefaultForeColor();
[JScript]
public static function get DefaultForeColor() : Color;

Property Value

The default foreground Color of the control. The default is SystemColors.ControlText.

Remarks

This is the default ForeColor property value of a nonparented control. Derived classes can have different defaults.

Example

[Visual Basic, C#] The following code example demonstrates how to use the DefaultBackColor, DefaultFont, and DefaultForeColor members. To run the example, paste the following code in a form containing a ListBox called ListBox1. Call the Populate_ListBox method in the form's constructor or Load method.

[Visual Basic] 

    ' 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

[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());

    }

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Control Class | Control Members | System.Windows.Forms Namespace | ForeColor | Color | SystemColors

Show:
© 2015 Microsoft