ClosingEventArgs 'Cancel' member already set to true by framework

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm having a difficult time trying to track this issue down. Hopefully,
someone might be able to share some insight.

I have a situation where a form is not closed when I explicitly call Close()
on it. As part of trying to debug this problem, I overrode the "OnClosing"
method (and OnFormClosing, too) and noticed that the 'Cancel' member of the
ClosingEventArgs parameter is already set to true upon entering and before I
explicitly forward the call to base.OnClosing(). If I force Cancel to be
false, then the form will close without a problem.

Does anyone have an idea why the framework is setting Cancel to true?

It is difficult to reproduce the problem with a small example. What I can
tell you is that the form in question is a TopLevel (and TopMost) form with
the Owner property set to an MDI child. The TopLevel form has a splitter
control that houses two child forms... however, I remove the splitter control
from the form before I call Close() (the form then contains no child
controls). This is the point where the form fails to close.
 
Back
Top