开发者

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!


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


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();
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜