Interpret the winform program response to keyboard events in C
- 2020-05-12 03:07:00
- OfStack
In the winform program, keyup events are added to form, but the program does not respond to keyboard events. The solution is to override the ProcessCmdKey(ref Message msg, Keys keyData) methods of the Form base class.
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (keyData == Keys.F4)
{
FormFastHitStates form = new FormFastHitStates();
form.ShowDialog();
}
return true;
//return base.ProcessCmdKey(ref msg, keyData);
}