Juan
Juan

Reputation: 15715

Need help tracking the origin of a weird problem

I'm working on an app that works with databases. Whenever I create more than one data table in my app, then erase one, and then try to close the app, it won't close. I added an event handler to the FormClosing event, and the Cancel property of FormClosingEventArgs is true. How can I track where is this property being set to true?

Upvotes: 2

Views: 65

Answers (1)

Bradley Smith
Bradley Smith

Reputation: 13601

This scenario is usually caused by one of the controls on your form being stuck in validation. If you are handling the Validating event on any controls and you set e.Cancel = true in the handler for that event, then the initial value of the Cancel property in the handler for FormClosing will also be true.

If, by chance, your database app is using a DataGridView control, one of the cells may still be in edit mode when you come to close the form.

Upvotes: 1

Related Questions