Поделиться через


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. Этот пример кода является частью более крупного примера, предоставленного в разделе "Практическое руководство. Настройка внешнего вида строк в элементе управления 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

Комментарии

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

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

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