Search code examples
c#winformskey-events

KeyPress\Up\Down doesn't work - C#


I have this code:

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


And I've set the event in the Form - but it simply isn't activated.
Other events like Resize or MouseDown work well, only this doesn't work.

Did someone ever experience this problem? What can I do ? [NO button works, neither characters or numerical or whatever].

Thanks, Mark!


Solution

  • Dis you set theForm1.KeyPreview = true for more info visit http://msdn.microsoft.com/en-us/library/system.windows.forms.form.keypreview%28v=VS.80%29.aspx