FormClosing event performed twice

  • Thread starter Thread starter Stefanie Knapp
  • Start date Start date
S

Stefanie Knapp

Hi,

I've got a problem with a .NET 2.0 application: When I try to cancel
the FormClosing event of the main form of the program (e.Cancel =
true), this same event is performed a second time (now it can be
cancelled successfully). The first time the FormClosing-method is
called with CloseReason.UserClosing, second time with
CloseReason.ApplicationExitCall. There is no call of Application.Exit()
before the FormClosing method is performed.

The form is an MDI parent, and this happens only when the MdiChildren
list is empty.

void MainFrame_FormClosing(object sender, FormClosingEventArgs e)
{
if (MessageBox.Show(this, "Do you really want to exit?", "Exit
program?",
MessageBoxButtons.YesNo, MessageBoxIcon.Question) !=
DialogResult.Yes)
{
e.Cancel = true;
return;
}
}

Why is the FormClosing event performed a second time with
CloseReason.ApplicationExitCall? Any suggestions?

Thanks in advance
Stefanie
 
Stefanie,

I can't reproduce your problem. I think there is something in your code that
causes it.

Can you post a simple compilable code that exposes this strange behavior?
 
Thanks for your answer. We use some resources from Syncfusion in our
application, and while trying to create a simple code I found out that
this only seems to happen when a TabbedMDIManager object is attached to
the main form... So I'm at least a bit closer to the solution of the
problem (I hope).
 
Hi,

we already use version 4.1.0.50 of Syncfusion Essential Studio.
The problem with the closing event happens only when all Mdi children
are closed.

Best regards,
Stefanie
 
Hi Stefanie,

Could you please create a Direct-Trac incident and get the latest
version of Essential Studio version which contains this fix?

Best Regards,
Mano Johnson,
Essential Tools Support Engineer,
Syncfusion Inc.
 
Back
Top