Setting AcceptButton to None still closes the form on ENTER.

Posted by Vilx- on Stack Overflow See other posts from Stack Overflow or by Vilx-
Published on 2010-03-20T20:35:43Z Indexed on 2010/03/20 20:41 UTC
Read the original article Hit count: 412

Filed under:
|
|

I have a MDI windows forms application and my child forms mostly have "OK" and "Cancel" buttons. However I do not want them to be activated with ENTER/ESC keys to prevent accidental saves/aborts. So, the form has both AcceptButton and CancelButton set to none. The ESC button indeed does nothing, but the ENTER button still closes the form by "clicking" on the first button found, sorted by TabOrder.

Why is this so? Must I really start doing workarounds and catching the ENTER key?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about winforms