how to trap/detect when entering textbox via tabkey?

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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.
 
Back
Top