Question

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!

Was it helpful?

Solution

OTHER TIPS

i think you have set like this..

 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();
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top