Using Tab key to look up information

Blake81

Well-known member
Joined
Feb 23, 2006
Messages
304
Location
Georgia, USA
Programming Experience
1-3
I'm trying to work on an application to help learn some different parts of VB a bit better. I'm going to keep a contact list in the database, and the application will look up contacts based on which field you entered (first name, last name, address, etc.). I'd like it to look up the contact when you hit Tab after entering the info. I tried putting messageboxes in the KeyDown and KeyPress events, but it doesn't catch the tab key and just tabs between textboxes. How can I do this? Thanks.
 
The PreviewKeyDown event and setting IsInputKey also works:
VB.NET:
Private Sub TextBox1_PreviewKeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.PreviewKeyDownEventArgs) _
Handles TextBox1.PreviewKeyDown
    If e.KeyCode = Keys.Tab Then
        e.IsInputKey = True
 
    End If
End Sub
 
Have you tried the lostfocus event? When a textbox loses focus it could automatically get the data from the database. That way it would still get the data, even though the user changed focus using the mouse
 
Just noticed your post. I've been busy with other things, but, yes, I actually did find the LostFocus event, and I think that will work for me.
 
Back
Top