DataGridView.CellStyleChanged Événement
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.
Se produit lorsque la Style propriété d’une DataGridViewCell modification est modifiée.
public:
event System::Windows::Forms::DataGridViewCellEventHandler ^ CellStyleChanged;
public event System.Windows.Forms.DataGridViewCellEventHandler CellStyleChanged;
public event System.Windows.Forms.DataGridViewCellEventHandler? CellStyleChanged;
member this.CellStyleChanged : System.Windows.Forms.DataGridViewCellEventHandler
Public Custom Event CellStyleChanged As DataGridViewCellEventHandler
Type d'événement
Exemples
L’exemple de code suivant illustre l’utilisation de ce membre. Dans l’exemple, un gestionnaire d’événements signale l’occurrence de l’événement CellStyleChanged . Ce rapport vous aide à apprendre quand l’événement se produit et peut vous aider à déboguer. Pour signaler plusieurs événements ou événements qui se produisent fréquemment, envisagez de MessageBox.ShowConsole.WriteLine remplacer ou d’ajouter le message à un multiligne TextBox.
Pour exécuter l’exemple de code, collez-le dans un projet qui contient une instance de type DataGridView nommée DataGridView1. Vérifiez ensuite que le gestionnaire d’événements est associé à l’événement CellStyleChanged .
private void DataGridView1_CellStyleChanged(Object sender, DataGridViewCellEventArgs e) {
System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "ColumnIndex", e.ColumnIndex );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "RowIndex", e.RowIndex );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "CellStyleChanged Event" );
}
Private Sub DataGridView1_CellStyleChanged(sender as Object, e as DataGridViewCellEventArgs) _
Handles DataGridView1.CellStyleChanged
Dim messageBoxVB as New System.Text.StringBuilder()
messageBoxVB.AppendFormat("{0} = {1}", "ColumnIndex", e.ColumnIndex)
messageBoxVB.AppendLine()
messageBoxVB.AppendFormat("{0} = {1}", "RowIndex", e.RowIndex)
messageBoxVB.AppendLine()
MessageBox.Show(messageBoxVB.ToString(),"CellStyleChanged Event")
End Sub
Remarques
Cet événement se produit lorsqu’une propriété renvoyée DataGridViewCellStyle par une DataGridViewCell.Style propriété est définie sur une nouvelle valeur ou lorsqu’une DataGridViewCell.Style propriété est définie sur une nouvelle DataGridViewCellStyle valeur avec au moins une valeur de propriété différente de l’objet de style de cellule précédent.
Pour plus d’informations sur la gestion des événements, consultez Gestion et déclenchement d’événements.