keydown event

  • Thread starter Thread starter Rob T
  • Start date Start date
R

Rob T

I have a simple windows app. On the form, I have one panel which displays
an image. I have a KeyDown event that I use to tweek the image depending on
which keys are hit. ie. ctrl-D, ctrl-A, etc. Works fine so far.

Now I've added a textbox (and there will be other controls) to the form, not
the panel. My KeyDown event no longer triggers. How do I get this event
to work if my mouse pointer is over the panel?

Thanks.

Things I've Tried:
-On the mouse move event for the panel, tried to setfocus to the panel.
cursor leaves the text box, but that's it.
-putting the controls into their own panel...nada.
 
Rob T said:
I have a simple windows app. On the form, I have one panel which displays
an image. I have a KeyDown event that I use to tweek the image depending
on which keys are hit. ie. ctrl-D, ctrl-A, etc. Works fine so far.

Now I've added a textbox (and there will be other controls) to the form,
not the panel. My KeyDown event no longer triggers. How do I get this
event to work if my mouse pointer is over the panel?

Set the form's 'KeyPreview' property to 'True' and capture the events in the
form's keyboard events.
 
Back
Top