Capturing TAB Key

Ok, I know how to capture Keys, but I can't seem to capture when the TAB key is pressed.  I know its a special case, but I can't get it.

Any ideas


Answer this question

Capturing TAB Key

  • Smiles

    Hhhmmm...good call.  Maybe (y)
  • Alex Titovich

    Yes, don't worry, they do call the same method.  I guess now I am just more curious as to why it doesn't rasie the events.  Probably some win32 programming feature I am clueless about.
  • Steve Adkins

    You can catch the TAB key by creating a new textbox derived from Textbox and override ProcessDialogKey.

  • B.Brown

    No.

    I tried KeyUp, KeyDown, KeyPress, and no luck.  I can use the Leave event of the textbox, but I was just trying to handle both the ENTER key and the TAB key at the same time.

  • vtrepan

    If you set Multiline and AcceptsTabs to True, you'll find that Tabs would then come through as characters
  • GanitMandir

    Do you have Multiline set to True
  • Lev Semenets

    oh, well the Leave Event is really what you'd want.  Having them together might be nice, but the Enter key and the Tab key do different things, so it would make sense for to be handled differently.  I'm sure you could have them both call the same Method to have your actual code in the same place though
  • Stephen Orr

    Well, I believe it's because Tabs are only accepted as a character in a Multiline TextBox.

    Here's the description of the AcceptsTab Property that makes me think that.

    <i>"Gets or sets a value indicating whether pressing the TAB key in a multiline text box control types a TAB character in the control instead of moving the focus to the next control in the tab order."</i>

  • Capturing TAB Key