Software Engineer

Hi,

As per MSDN, Form.Load Event says -

Occurs before a form is displayed for the first time.

What I observed -

If I set the WindowState property of the form to Maximized, the load event does not behave as expected.

The form is shown (visible property set to true), as soon as the the function specified for load event is called.

If I don't set WindowState property, the form is displayed after the complete execution of "load event associated function".

My question -

Is there a workaround for handling this

Thanks in advance.

With regards,




Re: Windows Forms General Settings WindowState Maximized makes load event fail

JohnWein

Set the WindowState to Maximized in the last statement in the Load event.





Re: Windows Forms General Settings WindowState Maximized makes load event fail

nobugz

At the time the Load event runs, the window handle is already created so the WindowState change takes effect immediately. To avoid this, assign the WindowState property in the constructor.