Keystrokes in Winforms app causing window to close unexpectedly
I have a strange issue that has arisen recently:
Whenever I enter text, even a single character, into a textbox in any Form in my application it causes the form and its parent to close. I've checked for the following so far:
- 开发者_如何转开发
- Errant/mis-assigned event handlers that may be interpreting a keystroke as a Form cancel
- I am using keypreview in several windows but debugging shows this to not be a cause
- Happens in any form of the application
- Happens even with brand new text boxes dropped on the form
- Tried removing the WithEvents declaration from text box declarations (VB.NET)
- The result is DialogResult.Cancel when I break the code after Show or ShowDialog
- The forms do not use AcceptButton or CancelButton properties (set to none)
- Note: I am modifying a large codebase with a lot of code that I have yet to touch
What else could be causing this strange behavior?
Press Ctrl+D, E (Debug, Exceptions) and tell Visual Studio to break whenever any exception is thrown, then see if there are any exceptions at work.
Press Ctrl+D, N (Debug, New Breakpoint, Break at Function) and set a breakpoint on
System.Windows.Form.OnClosing, then look at the call stack. (Alternatively, overrideOnClosingin the main form, then set a breakpoint in it)
The DialogResult of the button was set to 'Cancel" by accident. After change back to default value "None", the problem is solved. This is my story.
加载中,请稍侯......
精彩评论