form1_Resize()

  • Thread starter Thread starter JJ
  • Start date Start date
J

JJ

I have some custom actions to run after "Resizing a Form". I used the code
below, but my actions are taken before the Form is completely resized. That
is not what I wante. I wanted to Completely Resize my form first and then
run my custom codes. How do I do it? Please Help!!!!!!!!!!

Thanks

private void Form1_Load(object sender, System.EventArgs e)

{

this.Resize += new EventHandler(Form1_Resize);

}

private void Form1_Resize(object sender, System.EventArgs e)

{

//some code here

}
 
JJ said:
I have some custom actions to run after "Resizing a Form". I used the code
below, but my actions are taken before the Form is completely resized. That
is not what I wante. I wanted to Completely Resize my form first and then
run my custom codes. How do I do it? Please Help!!!!!!!!!!

Obviously, the resize function is called within load, since it has to
set the size of the form. The easiest way would be to set a private
bool variable in your form, set it when the Load function was done, and
check it in the Resize handler.

See changes below:
private bool bLoaded = false;
private void Form1_Load(object sender, System.EventArgs e)

{ bLoaded = false;

this.Resize += new EventHandler(Form1_Resize);

bLoaded = true;
}

private void Form1_Resize(object sender, System.EventArgs e)

{
if ( bLoaded == true )
{
 

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

Back
Top