Guarantee form KeyPress event is called

  • Thread starter Thread starter Alain Dekker
  • Start date Start date
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
 
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?
 
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
 
Back
Top