CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Detect TAB key

  1. #1
    Guest

    Detect TAB key

    I have problem detecting the TAB key. The Help said
    Keypress event can detect Enter, Tab, and Backspace
    keys. I tried with a form and two text boxes. I couldn't
    trap the TAB key in KeyPress or KeyUp, KeyDown events
    when I press the TAB. I then tried setting KeyPreview = True
    for the form. But still it didn't work.
    My key board is configured with United States 101.
    I'm using VB6 on Windows 98 Version 1, Pentium II 200Mhz.
    What do I miss here?


  2. #2
    Join Date
    Jan 2000
    Location
    CA
    Posts
    52

    Re: Detect TAB key

    As another alternative, if you are performing validation of the data in the text field when the tab key is pressed, the tab key will cause the text box control to Lose Focus. You could place your validation code into the TextBox_LostFocus event or into the Validate event as well. You don't seem to be able to trap the tab key press if there is another control that can gain focus. The order of event firing after the tab key is pressed is 'Validate' followed by 'LostFocus'.


    Good Luck...


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured