954,198 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

KeyPress event not working

Hey. I'm having a problem. In a form's constructor, I have:

this.KeyDown+=new KeyEventHandler(frmGScreen_KeyDown)


but the event handler does not invoke at all when I press a key on the keyboard. I know this because i have the code "txtOutput.Text="Event handler entered" as the first line of the handler, and nothing happens, and besides, the actions coded for specific keys do not execute.

I do have the form's KeyPreview property set to true. So this one truly stumps me. I just don't get it...

scru
Posting Virtuoso
1,629 posts since Feb 2007
Reputation Points: 975
Solved Threads: 140
 

try:

this.KeyPress+=new KeyEventHandler(frmGScreen_KeyDown)

If it doesnt work, show me the rest of the program; as the error is not in that line.

dahwan
Newbie Poster
2 posts since May 2007
Reputation Points: 10
Solved Threads: 1
 

I guess I should have marked this as solved because i did fix it quit a while ago....cant remember how though..

scru
Posting Virtuoso
1,629 posts since Feb 2007
Reputation Points: 975
Solved Threads: 140
 

Wow, i didnt realise this thread was so old. Sorry to bring it up again, but i found this thread as i was searching for tutorials on google.
Do you have an IM adress?

dahwan
Newbie Poster
2 posts since May 2007
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You