Export (0) Print
Expand All
Expand Minimize

DataGridView.ForeColor Property

Gets or sets the foreground color of the DataGridView.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

[BrowsableAttribute(false)]
public override Color ForeColor { get; set; }

Property Value

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

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.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft