我在项目的beforecloseproject事件中设置了如下代码,希望当我选择对话框的“是”时,系统能直接退出
Dim n As Integer = 0
Dim Result As DialogResult
For Each dt As DataTable In DataTables
If dt.HasChanges Then
Result = Messagebox.Show("数据未保存,确定要退出系统吗?","提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.No Then '如果用户选择否
n = n + 1
e.Cancel = True '
Exit For
Else
n = n + 1
Exit For
e.skipsave = True
Return
End If
End If
Next
If n <= 0 Then
Result = Messagebox.Show("确定要退出系统吗?","提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result = DialogResult.No Then '如果用户选择否
e.Cancel = True '
End If
End If
但为何系统在我点击“是”之后,仍弹出系统的退出提示窗口呢(如下图)?代码需要如何修改?
此主题相关图片如下:qq截图01.jpg

此主题相关图片如下:qq截图02.jpg
