Form1_Resize(..)

  • Thread starter Thread starter jj
  • Start date Start date
J

jj

I used the following code to trigger some actions when the form is resized.
It works fine ONLY when the form is restored or resized to smaller size. My
codes are not executed ( ibelieve...) when I try to maximize or resize it to
larger size.

Any hints are greatly appreciated.
Thanks
JJ
private boolean bLoaded ;

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)

{

//My code here ;

}
 
jj said:
I used the following code to trigger some actions when the form is resized.
It works fine ONLY when the form is restored or resized to smaller size. My
codes are not executed ( ibelieve...) when I try to maximize or resize it to
larger size.

It should work. Try this in a test project...

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace WindowsApplication1
{
public class Form1 : System.Windows.Forms.Form
{
private System.ComponentModel.Container components = null;
public Form1()
{
InitializeComponent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
private void InitializeComponent()
{
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 273);
this.Name = "Form1";
this.Text = "Form1";
this.Resize += new System.EventHandler(this.Form1_Resize);
}
#endregion
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
private void Form1_Resize(object sender, System.EventArgs e)
{
MessageBox.Show( "Resize" );
}
}
}


--
Regards,

Tim Haughton

Agitek
http://agitek.co.uk
http://blogitek.com/timhaughton
 
It should work like that. Put a breakpoint in the event handler and debug
hrough to see if it is infact being called.
 
Back
Top