What is the difference between form Form.Load, Form.Shown and Form.Activated events? What is the order in which they are fired?
The BeforeInsert (form) event triggers as soon as you start typing in the control. The AfterInsert (form) event triggers after you leave the record. The BeforeUpdate and AfterUpdate events for the controls on the form and for the new record occur after the BeforeInsert event and before the AfterInsert event.
The order would be Form. Load , which initializes the form and calls the controls, Form.
Load: This event occurs before a form is displayed for the first time.
The load event is called once all the components of the form are loaded. If you redisplay the form, its components load again and therefore the Load event is triggered once more.
See the Windows Forms Events Lifecycle:
The Load
event fires when the form has been initialized, after its handle has been created but before it is shown.
The Shown
event fires after the first time the form becomes visible, when you call form.Show()
(or form.Visible = true
).
If you hide your form, then show it again, Shown
will fire again. (But Load
won't)
The Activate
event fires when the user switches to your form.
If the user switches to a different program (or form), then switches back to your form, Activate
will fire again.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With