KeyPress \ Up \ Down not working - C #

I have this code:

private void Form1_KeyDown(object sender, KeyEventArgs e) { MessageBox.Show("Fail!"); } 


And I set the event to Form , but it's just not activated.
Other events, such as Resize or MouseDown , work well, only this does not work.

Has anyone ever encountered this problem? What can I do? The [NO button works, neither characters, nor numeric, nor others].

Thank you Mark!

+4
source share
2 answers
+11
source

I think you did that.

  KeyPreview property set to true 

and try this .....

 int _i = 0; private void Form1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) { label1.Text = (++_i).ToString(); } } 
+3
source

All Articles