Hi All,
I need to submit a form when the user presses enter. No problem I think
to myself - I'll just use the KeyDown event of the form. So I've added
an event handler for that event (and the other Key events) and
everything builds, but I can't seem to get the events to fire :-(
Can anyone think why this might happen? Am I supossed to do this sort of
thing in the Form's Key down event? I need the form to submit no matter
which control on the form has focus.
Many thanks to anyone who can help
Simon
Kevin Spencer - 22 Feb 2007 13:36 GMT
Have you set the Form's KeyPreview proepty to true?

Signature
HTH,
Kevin Spencer
Microsoft MVP
Software Composer
http://unclechutney.blogspot.com
I had the same problem once. Fixed it using the same solution.
> Hi All,
>
[quoted text clipped - 10 lines]
>
> Simon
Simon Harvey - 22 Feb 2007 16:56 GMT
> Have you set the Form's KeyPreview proepty to true?
Hmm - I'll have a look at that. I've never actually heard of it so the
answers no....
>Add a button control to the form and assign it to the form's
'AcceptButton' property.
I can't - I'm using toolstrip buttons which dont seem to work as the
accept buttons for the form. I'd rather get the keyboard thing working
anyway
:-)
Thanks for your help
Herfried K. Wagner [MVP] - 22 Feb 2007 13:48 GMT
"Simon Harvey" <nothanks@hotmail.com> schrieb:
> I need to submit a form when the user presses enter. No problem I think to
> myself - I'll just use the KeyDown event of the form. So I've added an
> event handler for that event (and the other Key events) and everything
> builds, but I can't seem to get the events to fire :-(
Add a button control to the form and assign it to the form's 'AcceptButton'
property.

Signature
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>