Winform窗体事件发生顺序

 

Form 和Control 类公开了一组与应用程序启动和关闭相关联的事件。当Windows 窗体应用程序启动时,主窗体的启动事件按以下顺序引发:
 
System.Windows.Forms.Control.HandleCreated  在为控件创建句柄时发生。
 
System.Windows.Forms.Control.BindingContextChanged  BindingContext 属性的值更改时发生。
 
System.Windows.Forms.Form.Load   在第一次显示窗体前发生。
 
System.Windows.Forms.Control.VisibleChanged  在 Visible 属性值更改时发生。
 
System.Windows.Forms.Form.Activated  当使用代码激活或用户激活窗体时发生。
 
System.Windows.Forms.Form.Shown   只要窗体是首次显示就发生。
 
当应用程序关闭时,主窗体的关闭事件按以下顺序引发:
 
System.Windows.Forms.Form.Closing   发生于表单正在关闭时
 
System.Windows.Forms.Form.FormClosing 关闭窗体前发生。
 
System.Windows.Forms.Form.Closed  关闭窗体
 
System.Windows.Forms.Form.FormClosed   关闭窗体后发生。
 
System.Windows.Forms.Form.Deactivate  当窗体失去焦点并不再是活动窗体时发生。
 
Application 类的ApplicationExit 事件在主窗体的关闭事件之后引发。
 
 因此,如果你想让窗体在加载后自动隐藏,就应该把隐藏语句加在Shown里而不是Load。

posted @ 2016-05-27 16:16  寒夜美美  阅读(644)  评论(0编辑  收藏  举报