Passing keyboard event to another control

  • Thread starter Thread starter Jason Allen
  • Start date Start date
J

Jason Allen

When the user is typing into a TextBox, I'd like to be able to pass the
KeyUp event to a ListView control on the same form. This is so they can
press the up or down arrow keys and these will get sent to the ListView, but
all other keys will get handled by the TextBox.

I've looked into calling myForm.OnKeyUp but it doesn't allow you to specify
which control you want the OnKeyUp event to go to.

Next I tried calling SendMessage via pinvoke, and that does allow me to send
the WM_KEYUP message to the ListView control, but nothing happens in the
ListView when it recieves the message. It should select a different item
when I send WM_KEYUP with wParam set to Keys.Down, but it looks like its
ignoring the keyboard message, possibly because it doesn't have focus.

Anyone have any idea how to get this to work?

Thanks,

Jason A.
 
Your SendMessage approach should work if you use WM_KEYDOWN instead
So pass KeyDown events instead of KeyUp

/claes
 
Back
Top