4
這是DataGridView中的我RowValidation功能無法刪除:未能驗證,但在DataGridView中
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:無法在此事件處理程序中執行操作
如何更正此問題並仍然刪除該行?
你剛剛救了我無痛的痛苦,謝謝! – matao 2011-09-29 06:36:57