【发布时间】:2014-07-28 07:55:42
【问题描述】:
在我的 mdiMain 中,我有这个代码集。
Private Sub mdiMain_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
e.Cancel = IIf(MsgBox("Closing this window will log you out. Are you sure?", MsgBoxStyle.YesNo, "Log out?") = MsgBoxResult.Yes, False, True)
End Sub
我这样做的原因是捕获所有关闭表单的触发器。如果用户单击注销按钮,或者他们按下窗口右上角的 x 按钮,或者即使他们按下 Alt-F4。在同一个MDI的FormClosed下,确认退出后有一组指令。我的问题是我还有一个过程,用户被强制退出程序。由于用户被“强制”注销,因此应绕过确认对话框。但是不知道怎么绕过FormClosing事件,直接跳到FormClosed。
到目前为止,我只提出了一种方法,那就是设置一个布尔触发器。类似的东西
Private Sub mdiMain_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing
If ForceLogOut = True Then Exit Sub
e.Cancel = IIf(MsgBox("Closing this window will log you out. Are you sure?", MsgBoxStyle.YesNo, "Log out?") = MsgBoxResult.Yes, False, True)
End Sub
但是为了知识,我仍然想听听其他人的其他方法。
【问题讨论】:
标签: vb.net