10/04/2018

Event KeyDown not work

Event KeyDown is used in Winforms in the UI form.
Sometimes there is a problem when the event does not come.
Nothing happens when you press the keyboard keys.
Why this happens is not known.
One of the solutions to this problem is to turn on property KeyPreview.

private void Form1_KeyDown(object sender, KeyEventArgs e)
{
 if (e.Control && e.KeyCode == Keys.O)
 {
  MessageBox.Show("Hello!");
 }
}

No comments:

Post a Comment