Reputation: 1124
Hey guys so I'm trying to receive the column/row of the last edited cell however when I use the following code, what I receive is the cell that I select next(by clicking), since it is the one that is being selected.
Any way around this? Maybe I just don't have the right properties for the dataGridView
private void dataGridView1_CellEndEdit_1(object sender, DataGridViewCellEventArgs e)
{
int column = dataGridView1.SelectedCells[0].ColumnIndex;
int row = dataGridView1.SelectedCells[0].RowIndex;
}
Upvotes: 0
Views: 397
Reputation: 33839
DataGridViewCellEventArgs
provides data for DataGridView events related to cell and row operations. It exposes two properties ColumnIndex
and RowIndex
int column = e.ColumnIndex;
int row = e.RowIndex;
More: As @Mr_Green pointed, e.ColumnIndex
and e.RowIndex
will be -1
for ColumnHeader & RowHeader
.
Upvotes: 1
Reputation: 20469
private void dataGridView1_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
int column = e.ColumnIndex;
int row = e.RowIndex;
}
Upvotes: 1