Stopping an application from closing

J

Joe_Black

Hi All,

I want to stop my app from closing, unless the user specifically wants
it to, I use this code:

private void MainForm_Closing(object sender,
system.ComponentModel.CancelEventArgs e)
{
if(MessageBox.Show("Are you sure you wish to close Millenium?",
"Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
== DialogResult.No)
{
e.Cancel = true;
}
}

The main form of my application calls this function on the Closing event.

The problem is this function never gets called, does any one know why
this may be the case, or should I be doing this elswhere?

Thanks

Joe
 
J

Joe_Black

Joe_Black said:
Hi All,

I want to stop my app from closing, unless the user specifically wants
it to, I use this code:

private void MainForm_Closing(object sender,
system.ComponentModel.CancelEventArgs e)
{
if(MessageBox.Show("Are you sure you wish to close Millenium?",
"Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
== DialogResult.No)
{
e.Cancel = true;
}
}

The main form of my application calls this function on the Closing event.

The problem is this function never gets called, does any one know why
this may be the case, or should I be doing this elswhere?

Thanks

Joe

All Sorted, thanks anyway

Joe
 

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