Keystrokes inside a Panel

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

Guest

How would I be able to process keystrokes inside a Panel? The panel class has no KeyDown event, and I even tried to make a custom Panel derived from Panel, and used its OnKeyDown to create an event, but it doesn't fire when a key is pressed! I'm using this panel on a control I'm making, and I'm drawing to the panel (it has no controls in it, I'm just using it because of its AutoScroll advantages).

So how would I record keystrokes? I can have the control surface do it, but it's covered by the panel, so it doesn't record them either...

Thanks!

Yaron
 
Yaron,

Are you sure that the panel has focus? I think that by default, it does
not, so you will never be able to capture keystrokes. If you enable the
panel so that it can get focus (set the TabStop property to true), you
should be able to capture keystrokes.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Yaron said:
How would I be able to process keystrokes inside a Panel? The panel class
has no KeyDown event, and I even tried to make a custom Panel derived from
Panel, and used its OnKeyDown to create an event, but it doesn't fire when a
key is pressed! I'm using this panel on a control I'm making, and I'm
drawing to the panel (it has no controls in it, I'm just using it because of
its AutoScroll advantages).
So how would I record keystrokes? I can have the control surface do it,
but it's covered by the panel, so it doesn't record them either...
 
Back
Top