|
-
Jun 12th, 2002, 05:20 AM
#1
Thread Starter
Frenzied Member
Key Pressed
On my form I have a textbox and a grid. The textbox has Tab Index 0 and Grid has Tab Index 1 (these cannot be changed). When I press tab in the textbox it automatically sends focus to the grid, however I want the code to do something when tab is pressed.
Code I have tried:
Code:
Private Sub txtBox_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyTab
' Do this
Case vbKeyReturn
' Do this
End Select
Strange thing is it will go into the code if I press return but not if I press tab
-
Jun 12th, 2002, 05:37 AM
#2
Bouncy Member
i think you would have to catch it in the keydown event, or if not then try the forms keydown event. by the time that the keypress event has fired, the tab key has been pressed and focus will be moved to the next control
-
Jun 12th, 2002, 06:13 AM
#3
Thread Starter
Frenzied Member
i think you would have to catch it in the keydown event
I am using the keydown event
Code:
Private Sub txtBox_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyTab
' Do this
Case vbKeyReturn
' Do this
End Select
End Sub
I have tried the Form_Keydown event also but it doesn't work
Any other suggestions?
-
Jun 12th, 2002, 06:43 AM
#4
Hyperactive Member
Just a small trick, set the property tabstop of the grid to false. Otherwise you should subclass your form and catch the Tab key.
3rd option is to place a hook on Keyboard_LL with setwindowshook and catch VK_Tab I think.
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
|