I have a WinForms form that won\'t close. In OnFormClosing, e.Cancel is set to true. I am guessing that some object in my application has bound to the Closing or FormClosing
The problem might be that the form doesn't validate.
The FormClosing event is raised by the private WmClose method in Form, which initializes e.Cancel to !Validate(true). I haven't investigated, but in certain circumstances, Validate will always return false, causing the close to be canceled regardless of any event handlers.
To investigate this, enable .Net source debugging, put a breakpoint in your FormClosing handler, go to the source for Form.WmClose (up the call stack), put a breakpoint at the beginning of WmClose, and close the form again. Then, step through it in the debugger and see why Validate is returning false. (Or which event handler is setting e.Cancel to true)
To solve the problem, set e.Cancel to false in your own handler.