如何Private Sub Form1_FormClosing中取消关闭窗体,
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Dim myti As Integer myti = MsgBox("确定关闭此窗体", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "提示")
Select Case myti
Case myti = MsgBoxResult.Yes e.Cancel = False
End
Case myti = MsgBoxResult.No e.Cancel = True
End Select
End Sub
这个我实在网上搜的。好像是VS2005的。
我现在用的vs2008。想使用这种方法取消关闭窗体,但是没有e.Cancel = True 。请高手指教!
[解决办法]
Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs)
If MessageBox.Show("是否现在关闭窗口", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) <> DialogResult.OK Then
e.Cancel = True
End If
End Sub