vb.net FormClosed 和 FormClosing 事件的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33004874/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Difference between FormClosed and FormClosing event
提问by Cary Bondoc
In VB.NETwhat is the difference between FormClosedand FormClosingevent?
在VB.NET之间有什么区别FormClosed和FormClosing事件?
Private Sub frmTerminal_TCP_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing
End Sub
Private Sub frmTerminal_TCP_FormClosed(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
End Sub
回答by Code Different
FormClosinghappens before FormClosed. Think of FormClosinglike the dialog that ask you to save your document before quitting the program. It gives you an opportunity to cancel the window's termination.
FormClosing发生在FormClosed. 想想像FormClosing在退出程序之前要求您保存文档的对话框。它使您有机会取消窗口的终止。
FormClosedis triggered after the form has closed. From MS documentation:
FormClosed在表单关闭后触发。从MS 文档:
The FormClosed event occurs after the form has been closed by the user or by the Close method or the Exit method of the Application class. To prevent a form from closing, handle the FormClosing event and set the Cancel property of the CancelEventArgs passed to your event handler to true.
FormClosed 事件发生在用户或应用程序类的 Close 方法或 Exit 方法关闭窗体之后。要防止窗体关闭,请处理 FormClosing 事件并将传递给事件处理程序的 CancelEventArgs 的 Cancel 属性设置为 true。

