【发布时间】:2012-08-12 21:45:10
【问题描述】:
我有一个 DataGridView,其中有许多单元格的 ReadOnly 属性设置为 True。
当用户使用 tab 键在单元格中切换时,如果 ReadOnly 属性为 true,我想将焦点移动到下一个单元格上。我的代码如下:
private void filterGrid_CellEnter(object sender, DataGridViewCellEventArgs e)
{
if (!filterGrid.Rows[e.RowIndex].Cells[e.ColumnIndex].ReadOnly)
{
EditCell(sender, e);
}
else
{
//Move to the next cell
filterGrid.Rows[e.RowIndex].Cells[e.ColumnIndex + 1].Selected = true;
}
}
但是,当我运行上述代码时,我收到以下错误:
操作无效,因为它会导致对 SetCurrentCellAddressCore 函数的可重入调用。
我使用的是 C# 4.0
提前致谢。
【问题讨论】:
-
你可能想先做一些用户测试。这在数据输入过程中可能会非常令人不安。
-
一旦我得到这个工作,我会的!
标签: c# datagridview