Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WinForms event life cycle

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

like image 612
SoftwareGeek Avatar asked Apr 25 '10 18:04

SoftwareGeek


People also ask

Is WinForms still used in 2022?

The latest version of Windows Forms is for . NET 6 using Visual Studio 2022 version 17.0.

Is WinForms going away?

As we mentioned above, WinForms is still available but the status of “maintenance mode” likely means it has no long term future. As time passed by, especially in the last 5-10 years, new tools continued to mature and rise in popularity, and each one of them offered many powerful features.

What are the steps involved in the life cycle of a Windows Form?

Paint: This event occurs when the control is redrawn. Deactivate: This event occurs when the form loses focus and is not the active form. Closing: This event occurs when the form is closing. Closed: This event occurs when the form is being closed.

Is WPF harder than WinForms?

It is a little bit tough, time-consuming, and complex to use WPF as compared to WinForms.


1 Answers

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.

like image 61
ardila Avatar answered Sep 17 '22 17:09

ardila