TAB Key

Phylum

Centurion
Joined
Jun 20, 2003
Messages
105
Location
Canada
The search engine dosen't allow searches on 3 letter words, so I apologize if this has already been asked.

Is it possible to capture the TAB key? The form I am trying to do it on is set to key preview (for other reasons). When trying to detect the keypress (using key up or down) in a textbox the event isn't triggered. Is there a way around this?

Phylum
 
you need to look at the override sub which processes the keypreview, here's a quick example ...
Visual Basic:
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        KeyPreview = True
    End Sub

    Protected Overrides Function ProcessKeyPreview(ByRef m As System.Windows.Forms.Message) As Boolean
        If m.WParam.ToInt32 = 9 Then
            MessageBox.Show("you just clicked the TAB key!")
        End If

        Return False

    End Function
 
On the form level that will work. I want to capture it on the control level I.E. Inside a textbox. What I am trying to do is execute code when the user hits tab inside of the textbox, instead of just merely changing which control has focus.
 
Back
Top