Close Event

  • Thread starter Thread starter MDB
  • Start date Start date
M

MDB

Hello All,

For some reason when my form is closed the closed event is not being fired
off. The form is created using a start up class:

System.Windows.Forms.Application.Run(new frmMain());

Then in the InitializeComponent (which is called from withing the frmMain
class) it has this:

this.Closed +=new EventHandler(frmMain_Closed);

Then I also have this:
 
Must of hit enter sending the post before I was done:

Hello All,

For some reason when my form is closed the closed event is not being fired
off. The form is created using a start up class:

System.Windows.Forms.Application.Run(new frmMain());

Then in the InitializeComponent (which is called from withing the frmMain
class) it has this:

this.Closed +=new EventHandler(frmMain_Closed);

Then I also have this:

private void frmMain_Closed(object sender, EventArgs e)
{
//My code

}

for some reason, the Closed Event will not fire off and I can not figure out
why. Any suggestions?
 
Probably you have MinimizeBox set to true, which is the default. When you
click on the X, the form won't close but will instead minimize. Change
MinimizeBox to false (or provide a button or menu option that calls
this.Close()) and you will see the event fire.
 
Yep, that was it. Thanks for your reply!


Ginny Caughey said:
Probably you have MinimizeBox set to true, which is the default. When you
click on the X, the form won't close but will instead minimize. Change
MinimizeBox to false (or provide a button or menu option that calls
this.Close()) and you will see the event fire.
 
Hi,

You should also keep in mind that, if you call Application.Exit your form
close event will not triggered.

If you should call Application.Exit, you should call Form.Close for all
your open forms prior to that.

Thanks

Ercan Turkarslan
Microsoft Mobile Devices Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top