Reputation: 41
I would like to get column index of a DataGridView
inside the CellEndEdit
event.
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
int columnIndex = dataGridViewMsg.Columns[e.ColumnIndex].ToString();
}
Upvotes: 0
Views: 94
Reputation: 3855
You're almost there:
Just do
private void dataGridView1_CennEndEdit(object sender, DataGridViewCellEventArgs e)
{
int columnIndex = e.ColumnIndex;
}
That will give you the column index of the cell currently being edited.
Though you would probably just want to use e.ColumnIndex
for whatever it is you want to do to save the overhead of creating a new variable. It isn't clear from your question what the end goal is.
Upvotes: 1