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 для определения цвета, используемого для рисования содержимого. Переменная eимеет тип DataGridViewRowPostPaintEventArgs. Этот пример кода является частью более крупного примера, приведенного в разделе How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control.

// 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 доступно только для чтения. Хотя можно задать свойства объекта , DataGridViewCellStyle полученного с помощью InheritedRowStyle свойства , новые параметры не будут действовать.

Применяется к

См. также раздел