Keystrokes in Winforms app causing window to close unexpectedly
        Posted  
        
            by Paul Sasik
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Paul Sasik
        
        
        
        Published on 2010-04-01T17:59:11Z
        Indexed on 
            2010/04/01
            18:03 UTC
        
        
        Read the original article
        Hit count: 546
        
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?
© Stack Overflow or respective owner