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.
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();
}
}
精彩评论