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

China☆狼群 提交于 2019-12-05 17:49:35

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

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

The Shown event should do this for you.

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