By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,720 Members | 2,135 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,720 IT Pros & Developers. It's quick & easy.

Form1_KeyDown doesn't fire

P: n/a
Hi,
I have a C# from and I'm trying to add some code in onKeyDown event. But it
doesn't fire at all............

Any idea ?

Thanks a lot.
Nov 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
If a control on your form has focus, your form won't receive the message unless you set KeyPreview to true.
Nov 16 '05 #2

P: n/a
OnKeyDown will only fire for the control that currently has focus.

However, if you want to capture it in your form, you can set the KeyPreview
property (on the form) to "true", and the OnKeyxxx events will fire for the
form, then (if you didn't cancel them) for the control.

Note that the OnKeyxxx events won't fire on the form for all keys (like the
arrow keys)

"genc ymeri" <ge********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,
I have a C# from and I'm trying to add some code in onKeyDown event. But it doesn't fire at all............

Any idea ?

Thanks a lot.

Nov 16 '05 #3

P: n/a
oh.....I thought I had already set that :(

thanks a lot.

"Charlie Williams" <an*******@discussions.microsoft.com> wrote in message
news:D4**********************************@microsof t.com...
If a control on your form has focus, your form won't receive the message

unless you set KeyPreview to true.
Nov 16 '05 #4

P: n/a
oh.....I thought I had already set that :(

thanks a lot.
"Philip Rieck" <st***@mckraken.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
OnKeyDown will only fire for the control that currently has focus.

However, if you want to capture it in your form, you can set the KeyPreview property (on the form) to "true", and the OnKeyxxx events will fire for the form, then (if you didn't cancel them) for the control.

Note that the OnKeyxxx events won't fire on the form for all keys (like the arrow keys)

"genc ymeri" <ge********@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Hi,
I have a C# from and I'm trying to add some code in onKeyDown event. But

it
doesn't fire at all............

Any idea ?

Thanks a lot.


Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.