DataGridViewRowPostPaintEventArgs.State Propriété
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
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.