DataGridViewRowPostPaintEventArgs.InheritedRowStyle 属性          
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取应用于当前 DataGridViewRow 的单元格样式。
public:
 property System::Windows::Forms::DataGridViewCellStyle ^ InheritedRowStyle { System::Windows::Forms::DataGridViewCellStyle ^ get(); };public System.Windows.Forms.DataGridViewCellStyle InheritedRowStyle { get; }member this.InheritedRowStyle : System.Windows.Forms.DataGridViewCellStylePublic ReadOnly Property InheritedRowStyle As DataGridViewCellStyle属性值
一个包含应用于当前 DataGridViewCellStyle 的单元格样式的 DataGridViewRow。
示例
下面的代码示例演示如何使用 InheritedRowStyle 来确定用于绘制内容的颜色。 变量 e的类型为 DataGridViewRowPostPaintEventArgs。 此代码示例是 How to: Customize the Appearance of Rows in the Windows 窗体 DataGridView 控件中提供的更大示例的一部分。
// Determine the foreground color.
if ((e.State & DataGridViewElementStates.Selected) ==
    DataGridViewElementStates.Selected)
{
    forebrush = new SolidBrush(e.InheritedRowStyle.SelectionForeColor);
}
else
{
    forebrush = new SolidBrush(e.InheritedRowStyle.ForeColor);
}
' Determine the foreground color.
If (e.State And DataGridViewElementStates.Selected) = _
    DataGridViewElementStates.Selected Then
    forebrush = New SolidBrush(e.InheritedRowStyle.SelectionForeColor)
Else
    forebrush = New SolidBrush(e.InheritedRowStyle.ForeColor)
End If
注解
属性 InheritedRowStyle 包含与当前行的 InheritedStyle 属性相同的值。 直接访问 DataGridViewRow 中的 DataGridView 可能会影响性能。 InheritedRowStyle在 事件中使用 RowPostPaint 以避免取消共享行并保持最佳性能。
InheritedRowStyle 属性为只读。 尽管可以通过 属性设置检索InheritedRowStyle到的属性DataGridViewCellStyle,但新设置将不起作用。