I'm working on an app that works with databases. Whenever I create more than one data ta开发者_JAVA百科ble 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
?
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.
精彩评论