Share via


DataGridViewRowPostPaintEventArgs.InheritedRowStyle 屬性

定義

取得套用至目前 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.DataGridViewCellStyle
Public ReadOnly Property InheritedRowStyle As DataGridViewCellStyle

屬性值

DataGridViewCellStyle,包含要套用至目前 DataGridViewRow 的儲存格樣式。

範例

下列程式碼範例示範如何使用 InheritedRowStyle 來判斷用來繪製內容的色彩。 變數 的類型 eDataGridViewRowPostPaintEventArgs 。 此程式碼範例是如何:自訂 DataGridView 控制項中 Windows Forms資料列外觀中提供之較大範例的一部分。

// 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 屬性,但新的設定不會有任何作用。

適用於

另請參閱