None of the KeyXXX events seem to be firing on my form :-(

S

Simon Harvey

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
 
H

Herfried K. Wagner [MVP]

Simon Harvey said:
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.
 
S

Simon Harvey

Kevin said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top