I searched a lot for this error, about which many questions have already been asked, but this is not a solution to my problem. I get
The operation is invalid because it leads to a repeated call to the SetCurrentCellAddressCore function.
Scenario: I have datagridviewwith TextboxColumnI use CellBeginEditto convert it to ComboBoxColumn, and after that CellValidateI change ComboBoxColumn to TextboxColumn again. Codes work for everyone. but getting the indicated error in the exact line e.RowIndex = 2raises this exception, but other doses of the lines do not show the error. if I omitted this error and continue, then e.RowIndex = 2 the cell value will be empty, and the value of other rows will work.
Here is the code 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);
_dgvCoarseAggegateTest[e.ColumnIndex, e.RowIndex] = c;
_dgvCoarseAggegateTest[e.ColumnIndex, e.RowIndex].Value = s;
_dgvCoarseAggegateTest[e.ColumnIndex, 0].Value = s1;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
How to resolve this.
:
, - , , , ,
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).