DataGridView.ForeColor 属性

定义

获取或设置 DataGridView 的前景色。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; }
member this.ForeColor : System.Drawing.Color with get, set
Public Overrides Property ForeColor As Color

属性值

表示 Color 的前景色的 DataGridViewA Color that represents the foreground color of the DataGridView. 默认为 DefaultForeColor 属性的值。The default is the value of the DefaultForeColor property.

属性

注解

@No__t 的属性为环境属性。The ForeColor property is an ambient property. 环境属性是一个控件属性,如果未设置,则将从父控件中检索该属性。An ambient property is a control property that, if not set, is retrieved from the parent control. 例如,默认情况下,@no__t 0 将具有与父 @no__t 相同的 @no__t。For example, a Button will have the same BackColor as its parent Form by default. 有关环境属性的详细信息,请参阅 AmbientProperties 类或 @no__t 类概述。For more information about ambient properties, see the AmbientProperties class or the Control class overview.

由于 @no__t 0 是不可变的(这意味着你无法调整其任何属性),因此你只能将 @no__t 的属性分配给新的 Font 对象。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.

@No__t-0 控件使用 @no__t 属性的值作为 @no__t 属性返回的 @no__t 3 的 ForeColor 属性的默认值。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. 更改 @no__t 值0会自动更新 @no__t 属性,从而更改继承该值的任何单元格的前景文本颜色。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. 有关单元样式继承的详细信息,请参阅Windows 窗体 DataGridView 控件中的单元格样式For more information about cell style inheritance, see Cell Styles in the Windows Forms DataGridView Control.

适用于

另请参阅