vb.net 关闭程序
好的简单方法是使用以下概念:
Private Sub frmMain_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
'check the close reason why form is closing
If e.CloseReason <> CloseReason.WindowsShutDown Then
' if windows is NOT shutting down then
'code what to do if user clicks X goes here
'example:
If MsgBox("Do you want to exit application?", MsgBoxStyle.Exclamation + MsgBoxStyle.YesNo, "Application exit") = MsgBoxResult.No Then e.Cancel = True
Else
'shuts down your application quietly
End If
End Sub
vb.net 关闭程序
本文介绍了一种在VB.NET中优雅关闭程序的方法,通过在FormClosing事件中检查关闭原因,实现用户确认退出或静默关闭,避免了Windows关闭时的询问框。
211

被折叠的 条评论
为什么被折叠?



