WinForms event life cycle

后端 未结 2 1439
长发绾君心
长发绾君心 2020-12-29 06:31

Just like there is Page life cycle in web applications, what is the event life cycle for WinForms, especially between Form and User Controls?

2条回答
  •  星月不相逢
    2020-12-29 07:30

    According to MSDN:

    Startup events of the main form are raised in the following order:

    Control.HandleCreated
    Control.BindingContextChanged
    Form.Load
    Control.VisibleChanged
    Form.Activated
    Form.Shown
    

    Shutdown events of the main form are raised in the following order:

    Form.Closing
    Form.FormClosing
    Form.Closed
    Form.FormClosed
    Form.Deactivate
    Application.ApplicationExit *
    

    I'm aware this is an old question, but I thought I'd include an actual answer since most are mere links.

提交回复
热议问题