DataGridViewRowPostPaintEventArgs.State Właściwość

Definicja

Pobiera stan bieżącej DataGridViewRowwartości .

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

Wartość właściwości

Bitowa kombinacja DataGridViewElementStates wartości, która określa stan wiersza.

Przykłady

W poniższym przykładzie kodu pokazano, jak za pomocą State właściwości określić, czy jest zaznaczony bieżący wiersz. Zmienna , ejest typu DataGridViewRowPostPaintEventArgs. Ten przykład kodu jest częścią większego przykładu przedstawionego w temacie How to: Customize the Appearance of Rows in the Windows Forms DataGridView Control (Dostosowywanie wyglądu wierszy w kontrolce 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

Uwagi

Tej właściwości można użyć do określenia, czy wiersz jest zamrożony, tylko do odczytu, czy wybrany między innymi stanami.

Dotyczy

Zobacz też