我为这个错误搜索了很多很多相同的问题,但它并没有解决我的问题。我正进入(状态
操作无效,因为它会导致对 SetCurrentCellAddressCore 函数的可重入调用。
场景是我 使用datagridview
它来转换它,然后我再次将 ComboBoxColumn 更改为 TextboxColumn。这些代码适用于所有人。但是在确切的行中得到所述错误会引发此异常,但其他行不会显示错误。如果我忽略此错误并继续,则 e.RowIndex = 2 单元格值变为空白,其他行值有效。TextboxColumn
CellBeginEdit
ComboBoxColumn
CellValidate
e.RowIndex = 2
这是代码CellBeginEdit
if (e.ColumnIndex == 2 && e.RowIndex >= 0)
{
try
{
string s = Convert.ToString(_dgvCoarseAggegateTest[e.ColumnIndex, e.RowIndex].Value);
string s1 = Convert.ToString(_dgvCoarseAggegateTest[e.ColumnIndex, 0].Value);
DataGridViewComboBoxCell c = new DataGridViewComboBoxCell();
string _SizeName = _cGetParrent._mGetParentCellValue(ref _dgvCoarseAggegateTest, e.RowIndex, 1);
_mFillSieveSizeGridCombo(_mGetMetalSizeID(_SizeName), ref c); // Here My Combo Will GetValues from SQL and it Returning Value
_dgvCoarseAggegateTest[e.ColumnIndex, e.RowIndex] = c; // Heres the error When e.RowIndex == 2 and if e.RowIndex != 2 then no error
_dgvCoarseAggegateTest[e.ColumnIndex, e.RowIndex].Value = s;
_dgvCoarseAggegateTest[e.ColumnIndex, 0].Value = s1;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
如何解决这个问题。
更新: 没有行用户将添加新行并选择值,基本的事情是我想从数据库中显示组合和填充值,填充值取决于条件,所以每次新值都会出现,
样本数据
testTable
1 A
2 B
3 C
4 D
5 E
6 F
7 G
8 H
9 I
在第 1 列中,我添加了一个值从 1 到 9 的组合,在_mFillSieveSizeGridCombo
我将 id 传递给 sql server 2008 并使用Combo.Item.Add(x)
方法填充组合。