对于关注对 Windows 窗体应用程序中引发的每个事件按次序进行处理的开发人员来说,事件引
发的顺序特别重要。当某种情况需要小心处理事件时(如重绘窗体的某些部分时),必须知道
事件在运行时的确切引发顺序。本文提供了一些有关在应用程序和控件的生命周期中的几个重
要阶段中的事件顺序的详细信息
当 Windows 窗体应用程序启动时,主窗体的启动事件按以下顺序引发:
System.Windows.Forms.Control.HandleCreated
System.Windows.Forms.Control.BindingContextChanged
System.Windows.Forms.Form.Load
System.Windows.Forms.Control.VisibleChanged
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 事件在主窗体的关闭事件之后引发。