Results 1 to 11 of 11

Thread: [RESOLVED] [2008] Keydown not recognizing Tab

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2008
    Location
    Nowhere
    Posts
    427

    Resolved [RESOLVED] [2008] Keydown not recognizing Tab

    Im having trouble with my VB.net code recognizing the Tab button while pressed. It recognizes regular letters but not Tab and i dont know why... Heres what im using:

    Doesnt work:

    Vb.net Code:
    1. Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles idbox.KeyDown
    2.         If e.KeyCode = Keys.Tab Then
    3.             MsgBox("Key pressed")
    4.         End If
    5.     End Sub

    Works:


    VB.net Code:
    1. Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles idbox.KeyDown
    2.         If e.KeyCode = Keys.T Then
    3.             MsgBox("Key pressed")
    4.         End If
    5.     End Sub
    "Programming is like sex. One mistake and you have to support it for the rest of your life." ~Michael Sinz


    Code Snippets/Usefull Links:
    WinRAR DLL|Vista Style Form|Krypton Component Library|Windows Form Aero|Parsing XML files|Calculate File's CRC 32|Download a list of files.

  2. #2
    Hyperactive Member syntaxeater's Avatar
    Join Date
    Dec 2006
    Location
    Des Moines, IA
    Posts
    460

    Re: [2008] Keydown not recognizing Tab

    idbox.acceptstab = true

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2008
    Location
    Nowhere
    Posts
    427

    Re: [2008] Keydown not recognizing Tab

    Doesnt work either. What im trying to do is when im in game and press the tab button i want it to move the selection to a textbox instead of on a button.
    "Programming is like sex. One mistake and you have to support it for the rest of your life." ~Michael Sinz


    Code Snippets/Usefull Links:
    WinRAR DLL|Vista Style Form|Krypton Component Library|Windows Form Aero|Parsing XML files|Calculate File's CRC 32|Download a list of files.

  4. #4
    Hyperactive Member syntaxeater's Avatar
    Join Date
    Dec 2006
    Location
    Des Moines, IA
    Posts
    460

    Re: [2008] Keydown not recognizing Tab

    ...is when im in game and press the tab button i want...
    Expand on this a little for us. Does your form have focus when tab is being pressed (in other words, does your application run in the background and is supposed to be handling keystrokes from this "game").

    Or... Is this application a game in and of itself?

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2008
    Location
    Nowhere
    Posts
    427

    Re: [2008] Keydown not recognizing Tab

    The application is a game and im having the same issues with a regular form. I cant get the keydown to handle the tab button as i want it to.
    "Programming is like sex. One mistake and you have to support it for the rest of your life." ~Michael Sinz


    Code Snippets/Usefull Links:
    WinRAR DLL|Vista Style Form|Krypton Component Library|Windows Form Aero|Parsing XML files|Calculate File's CRC 32|Download a list of files.

  6. #6
    Hyperactive Member syntaxeater's Avatar
    Join Date
    Dec 2006
    Location
    Des Moines, IA
    Posts
    460

    Re: [2008] Keydown not recognizing Tab

    Ok, two more questions and we should have close to enough enviroment details to tell you why.

    1)
    press the tab button i want it to move the selection to a textbox instead of on a button
    This statement makes me wonder if the focus is on the textbox. The keydown only will fire when the focus is already IN the textbox, not when it is gained from somewhere else.

    2) Is the game running on a seperate window (as in another form in your application) than these controls, or the same?

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2008
    Location
    Nowhere
    Posts
    427

    Re: [2008] Keydown not recognizing Tab

    1. After i click into the textbox and i press tab it moves to the button instead of the other textboxt beside it and i dont want that happening.
    2. The game is running in the same window as the controls.

    Also i tried it with a regular form and for some reason it still doesnt handle the tab button.
    "Programming is like sex. One mistake and you have to support it for the rest of your life." ~Michael Sinz


    Code Snippets/Usefull Links:
    WinRAR DLL|Vista Style Form|Krypton Component Library|Windows Form Aero|Parsing XML files|Calculate File's CRC 32|Download a list of files.

  8. #8
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: [2008] Keydown not recognizing Tab

    What is the .TabIndex value of the 1st Textbox and also of the 2nd Textbox. If you want the focus to move to the 2nd textbox from the first then the TabIndex property of the 2nd textbox should be 1 more than the 1st one so for example if the .TabIndex value of the 1st Textbox is 5 then the .TabIndex value of the 2nd Textbox should be 6

    Hope this is what you want?
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  9. #9
    Hyperactive Member syntaxeater's Avatar
    Join Date
    Dec 2006
    Location
    Des Moines, IA
    Posts
    460

    Re: [2008] Keydown not recognizing Tab

    koolsid more or less got to the solution I was driving at.

    Also, if you never want a control to gain focus from tab, use:
    myControl.tabstop = false

    Also, it is not necessary for your control's tabindex to be 1 more than the previous. Tab will always jump based on two conditions. 1) index is the next highest in the order and 2) the control allows for tabstop.

  10. #10
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: [2008] Keydown not recognizing Tab

    Tab will always jump based on two conditions. 1) index is the next highest in the order and 2) the control allows for tabstop.
    Absolutely true

    It's is always good to keep it one number up. It avoids a lot of confusion
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2008
    Location
    Nowhere
    Posts
    427

    Re: [2008] Keydown not recognizing Tab

    Thanks that worked
    "Programming is like sex. One mistake and you have to support it for the rest of your life." ~Michael Sinz


    Code Snippets/Usefull Links:
    WinRAR DLL|Vista Style Form|Krypton Component Library|Windows Form Aero|Parsing XML files|Calculate File's CRC 32|Download a list of files.

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