当我尝试更新 datagridview 组合框的内容时,它会抛出 Operation is not valid,因为它会导致在 line ,node.Cells[(int)Parameters.eColumn.valueBySelectionColumn] = cboCell; 处对 SetCurrentCellAddressCore 函数进行可重入调用;
我怎么解决这个问题??谢谢
private void treeGridView1_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
try
{
if (e.Control.GetType() == new DataGridViewComboBoxEditingControl().GetType())
{
if ((cboEditor != null) && (cboEditor_EventHandler != null))
{
cboEditor.SelectedIndexChanged -= cboEditor_EventHandler;
}
cboEditor = (DataGridViewComboBoxEditingControl)e.Control;
cboEditor.SelectedIndexChanged += cboEditor_EventHandler;
if (this.treeGridView1.SelectedCells.Count > 0 &&
this.treeGridView1.SelectedCells[0].ColumnIndex == (int)Parameters.eColumn.valueBySelectionColumn)
{
TreeGridNode node = GetCurrentNode();
object cellValue = node.Parent.Cells[(int)Parameters.eColumn.sectionTypeColumn].Value;
Parameters.eSection section = (Parameters.eSection)dicSection[cellValue.ToString()];
this.treeGridView1.Focus();
switch (section)
{
case Parameters.eSection.UNIX_Script:
DataGridViewComboBoxCell cboCell = Parameters.ValidateChoice(Parameters.eSection.UNIX_Script,
node.Cells[(int)Parameters.eColumn.parameterTypeColumn].Value,
ref cboEditor);
if (cboCell != null)
{
***node.Cells[(int)Parameters.eColumn.valueBySelectionColumn] = cboCell;***
node.Cells[(int)Parameters.eColumn.valueBySelectionColumn].Style.BackColor =
node.Cells[(int)Parameters.eColumn.sequenceColumn].Style.BackColor;
}
break;
}
}
}
}
}