Guarantee form KeyPress event is called

A

Alain Dekker

With a form with lots of complex controls (Button, PictureBox, TextBox,
Label, etc) how do I guarantee that the form KeyPress event will be called
when I press a key?

Depending on what control has the focus I am struggling to get the form's
KeyPress event called!

Thanks,
Alain
 
J

Jeff Johnson

With a form with lots of complex controls (Button, PictureBox, TextBox,
Label, etc) how do I guarantee that the form KeyPress event will be called
when I press a key?

Depending on what control has the focus I am struggling to get the form's
KeyPress event called!

First "is it plugged in"-type question: you have the KeyPreview property of
the form set to true, right?
 
A

Alain Dekker

Doh! No, that was the problem. The form had been working as expected for
weeks until I added the first TextBox to the form. Now that I've set the
KeyPreview property to True it works as expected.

Thanks!
Alain
 

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