|
-
June 17th, 2010, 05:54 PM
#1
KeyDown event
Dear CodeGurus,
I am trying to assign some actions to the KeyDown event on my form (to any key, say 'a'), so I try the following:
HTML Code:
private void Form1_KeyDown(object sender, KeyEventArgs e)
{
if(e.KeyCode != Keys.ShiftKey && e.KeyCode != Keys.ControlKey)
MessageBox.Show(String.Format("{0:D}", e.KeyCode), "Message");
}
My understanding that this should pop-up the Message Window any time when I press any character key on the keyboard. However, this works only if I have no controls on the form, if there is anything on it I get nothing. Can anybody explain why this is happening? How can I get it to work???
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|