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

天涯浪子 提交于 2019-12-07 10:08:35

问题


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?


回答1:


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




回答2:


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




回答3:


The Shown event should do this for you.



来源:https://stackoverflow.com/questions/7932012/c-sharp-are-there-any-events-fired-right-after-loading-a-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!