我的表单中有一个简单的 OK/CancelDialogResult
实例:
MessageBox.Show("Number of records affected:" + numberOfRecordsroll + " Please check the data is correct before proceeding:", "Please validate your changes", MessageBoxButtons.OKCancel);
DialogResult dr = new DialogResult();
if (dr == DialogResult.OK)
{
// CommitTheChanges();
MessageBox.Show("test", "test");
}
else if (dr == DialogResult.Cancel)
{
//Do nothing
}
如您所见,如果用户单击“是”,CommitTheChanges
则应调用该方法,但这并未触发。此后,我将其注释掉并进行了测试MessageBox.Show()
。这又是行不通的。我在这里做错了什么?