FormClosing Event And Cancelling The Close

G

Guest

In a WinForm, in the FormClosing event, there is an opportunity to cancel the
close by setting the Cancel property of the FormClosingEventArgs to true.
This is typically done when there is unsaved data on the form and the user,
when asked if they want to close the form and lose data or not, says not to
close.

Our app is a MDI type that holds several windows. When the app gets closed,
each form in it gets closed, getting their FormClosing event, then the
mainframe form gets its FormClosing event. Problem I have is that the
mainframe needs to know if any of the forms in it canceled their close
(because of the above) and if they did the mainframe will cancel the app
closing. But how can the main form, in his FormClosing event, know that? Is
there a way?

Thanks
Rich Sienkiewicz
DragonPoint Software
(e-mail address removed)
 
G

Guest

Never mind I found out how to do it. In the mainframe's FormClosing event the
Cancel property will set to true if any mdi child canceled his close. In that
case do a return:

private void Frame_FormClosing(object sender, FormClosingEventArgs e)
{
if (e.Cancel == true)
return;
}

Rich Sienkiewicz
DragonPoint Software
(e-mail address removed)
 
G

Guest

Actually I had to do nothing, like the below, I just had to ensure that the
mdi children canceled their close.

Rich
 

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