C#, WinForms: What would prevent KeyDown events from chaining up from focused control up to main For

Posted by blak3r on Stack Overflow See other posts from Stack Overflow or by blak3r
Published on 2010-05-14T23:40:47Z Indexed on 2010/05/14 23:54 UTC
Read the original article Hit count: 250

Filed under:
|
|
|

As i understand it, when a keyboard button is pressed it should invoke the KeyDown event for the control which has focus. Then, the KeyDown for the parent control, so on and so forth until it reaches main form. UNLESS - along the chain one of the EventHandlers did:

e.SuppressKeyPress = true;
e.Handled = true;

In my case, KeyDown events never get to the main form. I have Form -> Panel -> button for example.

Panel doesn't offer a KeyDown Event, but it shouldn't stop it from reaching the main form right?

Right now as a work around I set every single control to call an event handler I wrote. I'm basically trying to prevent Alt-F4 from closing the application and instead minimize it.

© Stack Overflow or respective owner

Related posts about c#

Related posts about winforms