how to trap/detect when entering textbox via tabkey?

G

Guest

Hello,

I need to trap/detect when a textbox is entered via the tabkey. If the
textbox is not empty when entered via the tabkey then set focus to next
textbox. To enter that textbox would then require a mouseclick if it already
contains text to be edited. I am guessing that I would need to trap for
this in the Enter Event of this particular textbox.

I tried this in the Enter Event of the Textbox, but...

if ctype(sender,KeyValuePair(Of, " "))

obviously not working. I would be very grateful if someone could share how
to trap/detect when entering a textbox via the tabkey.

Thanks,
Rich
 
G

Guest

check out the textbox's GotFocus event. that is fired whenever the control
gets the focus, be it by the mouse or tab key, etc
 
G

Guest

Well, I came up with this

Private Sub txtM_KeyUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles txtM.KeyUp
If e.KeyCode.ToString.Equals("Tab") Then
If txtM.Text <> "" Then txtlastName.Focus()
End If
End Sub

Interestingly, it was the KeyUp event of the textbox where you can trap for
the tab key. Anyway, this seems to do what I want. Any other suggestions
appreciated.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top