DataGridView.ForeColor Property

Definition

Gets or sets the foreground color of the DataGridView.

public:
 virtual property System::Drawing::Color ForeColor { System::Drawing::Color get(); void set(System::Drawing::Color value); };
[System.ComponentModel.Browsable(false)]
public override System.Drawing.Color ForeColor { get; set; }
[<System.ComponentModel.Browsable(false)>]
member this.ForeColor : System.Drawing.Color with get, set
Public Overrides Property ForeColor As Color

Property Value

A Color that represents the foreground color of the DataGridView. The default is the value of the DefaultForeColor property.

Attributes

Remarks

The ForeColor property is an ambient property. An ambient property is a control property that, if not set, is retrieved from the parent control. For example, a Button will have the same BackColor as its parent Form by default. For more information about ambient properties, see the AmbientProperties class or the Control class overview.

Because the Font is immutable (meaning that you cannot adjust any of its properties), you can only assign the Font property a new Font object. However, you can base the new font on the existing font.

The DataGridView control uses the value of the ForeColor property as the default value of the ForeColor property of DataGridViewCellStyle returned by the DefaultCellStyle property. Changing the ForeColor value automatically updates the DefaultCellStyle property, changing the foreground text color for any cell that inherits the value. Header cells override the value by default, and you can override the value for specific rows, columns, and cells. For more information about cell style inheritance, see Cell Styles in the Windows Forms DataGridView Control.

Applies to

See also