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.
 
Thank you! That was too easy!

Herfried K. Wagner said:
Set the form's 'KeyPreview' property to 'True' and capture the events in
the form's keyboard events.
 

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

Back
Top