Partager via


DataGridViewRowPostPaintEventArgs.State Propriété

Définition

Obtient l’état du fichier actif 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

Valeur de propriété

Combinaison de valeurs au niveau du DataGridViewElementStates bit qui spécifie l’état de la ligne.

Exemples

L’exemple de code suivant montre comment utiliser la State propriété pour déterminer si la ligne active est sélectionnée. La variable, , eest de type DataGridViewRowPostPaintEventArgs. Cet exemple de code fait partie d’un exemple plus large fourni dans 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

Remarques

Cette propriété peut être utilisée pour déterminer si la ligne est figée, en lecture seule ou sélectionnée, entre autres états.

S’applique à

Voir aussi