KeyPress Not Firing

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a series of graphical User controls on the screen which which do not
posess any user input controls so no tab stops. I need to have them respond
to key press events to move left or right (arrow keys) or Delete. My problem
is I can't get the KeyPress event to fire for any keys standard or non
standard.

I have set the Form's Keypress property to True but want to capture the
keypress inside the UserControls themselves. I have Set the UserControl's
KeyPress Event as well as tried overriding the OnKeyDown, OnKeyPress, and
IsInputKey.

Still I am not triggering the KeyDown or KeyPress events.

Is there a trick to this???
 
Thanks Bob - ProcessCmdKey does trap the event on the form but not at the
UserControl level. Is there anyway to capture the event at the UserControl
or must the form be made "aware" of the various controls it holds and their
states?
 
It's the responsibility of each window to trab events when it has the focus.
As your user controls get the focus, they will be given the opportunity to
deal with events such as key press and mouse move etc. If you've done
nothing to these controls to handle the events they will just be ignored.

If you have control over the source for these user controls you must build
in the abilities you need or perhaps handle the correct events on the
controls to trap them in the form.

--
--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
Back
Top