Capture keys in UserControl

  • Thread starter Thread starter Tomaz Koritnik
  • Start date Start date
T

Tomaz Koritnik

I have an UserControl with a Textbox on it. TextBox captures keys (I assume
via overridden ProcessCmdKey method) and doesn't pass them onto parent (by
not calling base.ProcessCmdKey) therefore KeyDown is not trigered in parent
UserControl. I wan't to catch enter key in UserControl but I can't do that.
Is there any way to capture it before it reaches TextBox WITHOUT modifying
TextBox code?

regards
Tomaz
 
Try the KeyPreview property on the form. Should give you a chance to capture
them before the textbox,
If that doesn't work try attaching a messagefilter and watching for
WM_KEYDOWN, WM_KEYUP etc. Check out IMessageFilter for more info on this.

/claes
 
Back
Top