DataGridViewRowPostPaintEventArgs.State Vlastnost

Definice

Získá stav aktuálního 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

Hodnota vlastnosti

Bitové kombinace DataGridViewElementStates hodnot, která určuje stav řádku.

Příklady

Následující příklad kódu ukazuje, jak použít State vlastnost k určení, zda je vybrán aktuální řádek. Proměnná e, je typu DataGridViewRowPostPaintEventArgs. Tento příklad kódu je součástí většího příkladu v části Postupy: Přizpůsobení vzhledu řádků v ovládacím prvku model Windows Forms 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

Poznámky

Tuto vlastnost lze použít k určení, zda je řádek mimo jiné zablokovaný, jen pro čtení nebo vybraný.

Platí pro

Viz také