I have shortcut keys in my WinForms application, but I want to process them AFTER the child controls.
I'm using KeyDown event in the main control and the 'g' key is used to display a grid. But in the edit box within the main control, when I press the 'g' key, the grid is displayed and the edit box receives the 'g'. If I set the 'g' key handled by the shortcut, the edit box does not receive the 'g' key.
=> my goal is to have all the keys handled first by the children and then by the main window, if it's not been handled yet.
Here is a code snippet:
public ShortCutManager(Control Control, string Title)
{
_Control = Control;
_Control.KeyDown += OnKeyDown;
}
private void OnKeyDown(object Sender, KeyEventArgs KeyEventArgs)
{
if (KeyEventArgs.KeyCode == Keys.G)
{
// What I need
SendKeyEventToChildren(KeyEventArgs);
if (KeyEventArgs.Handled == false)
{
DoShortcutCommand();
KeyEventArgs.Handled = true;
}
}
}