Simon Verbeke
Simon Verbeke

Reputation: 3005

C# - are there any events fired right after loading a form?

I want to give the user the option to use a tutorial, the first time he uses the program. I tried adding it in the Form.Load event, but the forms shows up after the Messageboxes have popped up.

That's why I would like to know, are there any events fired right after loading a form?

If not, is there a way to perform actions right after loading?

Upvotes: 4

Views: 13134

Answers (3)

Kelsey
Kelsey

Reputation: 47766

You could try using the Shown event but that might be a bit early too based on what you are doing but it does occur after the Load.

If you have any controls on the page you could trigger it off the controls GotFocus event. Just make sure to put in checks to only do it once if using the GotFocus method.

MSDN Form.Shown

MSDN Control.GotFocus

MSDN Reference to order of events

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

Upvotes: 9

box86rowh
box86rowh

Reputation: 3415

You should try the shown event, which fires after the form is shown for the first time. Load happens before the form is shown.

Upvotes: 9

Kell
Kell

Reputation: 3327

The Shown event should do this for you.

Upvotes: 1

Related Questions