I am facing a problem in datagridview. I have done some code in keydown event for changing the tab focus but when tab reaches last of column it gives a error
"Current cell cannot be set to an invisible cell".
I have made last of cell is invisible because i don't want to be visible that cell.
I have written following code in KeyDown event
private void m3dgvDepositDetails_KeyDown(object sender, KeyEventArgs e)
{
try
{
if (e.KeyCode == Keys.Tab && notlastColumn)
{
e.SuppressKeyPress = true;
int iColumn = m3dgvDepositDetails.CurrentCell.ColumnIndex;
int iRow = m3dgvDepositDetails.CurrentCell.RowIndex;
if (iColumn == m3dgvDepositDetails.Columns.Count - 1)
m3dgvDepositDetails.CurrentCell = m3dgvDepositDetails[0, iRow + 1];
else
m3dgvDepositDetails.CurrentCell = m3dgvDepositDetails[iColumn + 1, iRow];
}
}
catch (Exception ex)
{
CusException cex = new CusException(ex);
cex.Show(MessageBoxIcon.Error);
}
}