Partager via


DataGridViewCellEventArgs.ColumnIndex Propriété

Définition

Obtient une valeur indiquant l'index de colonne de la cellule sur lequel se produit l'événement.

public:
 property int ColumnIndex { int get(); };
public int ColumnIndex { get; }
member this.ColumnIndex : int
Public ReadOnly Property ColumnIndex As Integer

Valeur de propriété

Index de la colonne contenant la cellule sur laquelle l'événement se produit.

Exemples

L’exemple de code suivant illustre l’utilisation de cette propriété.

private void dataGridView1_CellBeginEdit(object sender,
    DataGridViewCellCancelEventArgs e)
{
    string msg = String.Format("Editing Cell at ({0}, {1})",
        e.ColumnIndex, e.RowIndex);
    this.Text = msg;
}

private void dataGridView1_CellEndEdit(object sender,
    DataGridViewCellEventArgs e)
{
    string msg = String.Format("Finished Editing Cell at ({0}, {1})",
        e.ColumnIndex, e.RowIndex);
    this.Text = msg;
}
Private Sub dataGridView1_CellBeginEdit(ByVal sender As Object, _
    ByVal e As DataGridViewCellCancelEventArgs) _
    Handles DataGridView1.CellBeginEdit

    Dim msg As String = _
        String.Format("Editing Cell at ({0}, {1})", _
        e.ColumnIndex, e.RowIndex)
    Me.Text = msg

End Sub

Private Sub dataGridView1_CellEndEdit(ByVal sender As Object, _
    ByVal e As DataGridViewCellEventArgs) _
    Handles DataGridView1.CellEndEdit

    Dim msg As String = _
        String.Format("Finished Editing Cell at ({0}, {1})", _
        e.ColumnIndex, e.RowIndex)
    Me.Text = msg

End Sub

S’applique à

Voir aussi