-
Oct 20th, 2008, 03:04 PM
#1
Thread Starter
Hyperactive Member
[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:
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles idbox.KeyDown
If e.KeyCode = Keys.Tab Then
MsgBox("Key pressed")
End If
End Sub
Works:
VB.net Code:
Private Sub TextBox1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles idbox.KeyDown
If e.KeyCode = Keys.T Then
MsgBox("Key pressed")
End If
End Sub
-
Oct 20th, 2008, 03:35 PM
#2
Re: [2008] Keydown not recognizing Tab
-
Oct 20th, 2008, 03:38 PM
#3
Thread Starter
Hyperactive Member
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.
-
Oct 20th, 2008, 03:45 PM
#4
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?
-
Oct 20th, 2008, 03:48 PM
#5
Thread Starter
Hyperactive Member
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.
-
Oct 20th, 2008, 04:03 PM
#6
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?
-
Oct 20th, 2008, 04:08 PM
#7
Thread Starter
Hyperactive Member
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.
-
Oct 20th, 2008, 04:32 PM
#8
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
-
Oct 20th, 2008, 04:46 PM
#9
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.
-
Oct 20th, 2008, 04:50 PM
#10
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
-
Oct 20th, 2008, 05:04 PM
#11
Thread Starter
Hyperactive Member
Re: [2008] Keydown not recognizing Tab
Thanks that worked
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|