I am working on an editable grid where I can add, edit delete records.
But the problem is when I click Enter key, the selected cell whose editing is enabled the SelectionChanged
event gets triggered.
And because of this, the selected row gets changed to the next line.
I added CellEndEdit
event to make selected cell remains selected but the problem is the SelectionChanged
event trigger after CellEndEdit
private void DgvMaster_CellEndEdit(object sender, DataGridViewCellEventArgs e)
dgvMaster.CurrentCell = dgvMaster[dgvMaster.CurrentCell.ColumnIndex, dgvMaster.CurrentCell.RowIndex];
So, how can I prevent the SelectionChanged
event from firing or at least return in this case?
EditCell >> Click Enter >> End Edit >> Cell Remain same.
And also, is there any way to check whether the Cell Edit is enabled or disbaled.
What I have tried:
private void DgvMaster_KeyDown(object sender, KeyEventArgs e)
e.SuppressKeyPress = true;
int iColumn = dgvMaster.CurrentCell.ColumnIndex;
int iRow = dgvMaster.CurrentCell.RowIndex;
if (iColumn == dgvMaster.ColumnCount - 1)
if (dgvMaster.RowCount > (iRow + 1))
dgvMaster.CurrentCell = dgvMaster[1, iRow];
dgvMaster.CurrentCell = dgvMaster[dgvMaster.CurrentCell.ColumnIndex + 1, dgvMaster.CurrentCell.RowIndex];
dgvMaster.CurrentCell = dgvMaster[iColumn + 1, iRow];