我在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
“当前单元格不能设置为不可见的单元格”。
我已经使最后一个单元格不可见,因为我不想让那个单元格可见。
我在 KeyDown 事件中编写了以下代码
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);
}
}