C#, WinForms: Why aren't KeyDown events chaining up to Form? I have to add event handler to each chi

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:44 UTC
Read the original article Hit count: 474

Filed under:
|
|
|

As i understand it, when a button is pressed it should first invoke the Control which has focus' KeyDown Handler, then it call the KeyDown handler for any Parent controls, all the way up to the main form. The only thing that would stop the chain would be if somewhere 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