DataGridViewRowPostPaintEventArgs.State Свойство

Определение

Получает состояние текущей ячейки DataGridViewRow.

public:
 property System::Windows::Forms::DataGridViewElementStates State { System::Windows::Forms::DataGridViewElementStates get(); };
public System.Windows.Forms.DataGridViewElementStates State { get; }
member this.State : System.Windows.Forms.DataGridViewElementStates
Public ReadOnly Property State As DataGridViewElementStates

Значение свойства

Поразрядная комбинация значений DataGridViewElementStates, которая задает состояние строки.

Примеры

В следующем примере кода показано, как использовать State свойство , чтобы определить, выбрана ли текущая строка. Переменная 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

Комментарии

Это свойство можно использовать, чтобы определить, является ли строка замороженной, доступной только для чтения или выбранной, среди других состояний.

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

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