Order of Events on Form Creation

J

Jeff Gaines

This seems a really basic question but I can't find an answer in the
help file, perhaps I'm looking for the wrong thing?

I want to load the previous settings for my app which will indicate
window size and position. I can't do it in the load event because the
form doesn't actually exist (or is not visible) at that point.

I put it in the form activate event with a flag so the settings are
only applied once but this seems a bit clumsy.

Is there an 'on first activated' or 'on first show' event that I could
us. I am currently trying 'OnCreateControl' but I am not sure that
makes sense.

Many thanks.
 
G

Guest

As far as I can see, you're doing it the recommended way.

Yes, it seems very clumsy.
 
I

Imran Koradia

You should be able to set the size and position of the form in the load
event itself. Did you give that a try? It should work fine.

hope that helps..
Imran.
 
J

Jeffrey Tan[MSFT]

Hi Jeff,

Based on my understanding, you want to change the form size and position at
startup.

I am not sure what you are doing wrong, but I can successfully change the
form's default postion and size in Form_Load event, like this:
private void Form1_Load(object sender, System.EventArgs e)
{
this.Top=0;
this.Left=0;
this.Width=100;
this.Height=100;
}
================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
J

Jeff Gaines

Hi Jeff,

Based on my understanding, you want to change the form size and
position at startup.

I am not sure what you are doing wrong, but I can successfully change
the form's default postion and size in Form_Load event, like this:
private void Form1_Load(object sender, System.EventArgs e)
{
this.Top=0;
this.Left=0;
this.Width=100;
this.Height=100;
}
================================================
Thank you for your patience and cooperation. If you have any
questions or concerns, please feel free to post it in the group. I am
standing by to be of assistance.

Thanks to Jeffrey, 'policywatcher' and Imran.

I am using XMLSerialisation to load the settings and the problem lies
there, if the Serialisation works then the re-sizing works.

I have had some input elsewhere on the Serialisation and I'm working
through it.

Thanks again, at least I can now remove an un-needed function and flag
and concentrate on the real culprit :)
 
J

Jeffrey Tan[MSFT]

Hi Jeff,

Thanks very much for your feedback!

I am glad the winform related problem is resolved, if you need further
help, please feel free to tell me. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top