【发布时间】:2011-02-15 04:22:39
【问题描述】:
这是在我的 DataGridView 的 RowValidation 函数中:
DataGridViewRow row = viewApplications.Rows[e.RowIndex];
if (row.Cells[colApplyTo.Index].Value == (object)-1) {
if (MessageBox.Show("Row #" + (e.RowIndex + 1) + " is not assigned to a charge. Would you like to correct this? (If no, the row will be deleted)", "Invalid Row", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) {
viewApplications.Rows.RemoveAt(e.RowIndex);
} else {
e.Cancel = true;
}
}
但是,有一个问题,如果用户说不,这意味着他或她不想更正这一行,我不能像我尝试做的那样删除它。我得到了异常:InvalidOperationException:无法在此事件处理程序中执行操作
如何更正此问题并仍然删除该行?
【问题讨论】:
标签: c# datagridview