FormClosed和FormClosing事件之间的区别

时间:2015-10-08 00:56:51

标签: vb.net forms

VB.NET FormClosedFormClosing事件之间有什么区别?

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

1 个答案:

答案 0 :(得分:10)

FormClosing发生在FormClosed之前。将FormClosing想象为要求您在退出程序之前保存文档的对话框。它让您有机会取消窗口的终止。

表单关闭后会触发

FormClosed。来自MS documentation

  

FormClosed事件发生在用户关闭表单之后,或者由Close类或Application类的Exit方法关闭。若要防止表单关闭,请处理FormClosing事件并将传递给事件处理程序的CancelEventArgs的Cancel属性设置为true。