How to Detect the "TAB" Key is Pressed

G

Guest

How to Detect the "TAB" Key is pressed in the Text Box or Combo Box....
Which events catches the TAB key...
I Want to perform some operations when the "TAB" key is pressed...
 
H

Herfried K. Wagner [MVP]

Prabhudhas Peter said:
How to Detect the "TAB" Key is pressed in the Text Box or Combo Box....
Which events catches the TAB key...
I Want to perform some operations when the "TAB" key is pressed...

Add this to your form's code:

\\\
Protected Overrides Function ProcessTabKey( _
ByVal forward As Boolean _
) As Boolean
MyBase.ProcessTabKey(forward)
MsgBox("Tab key was pressed!")
End Function
///
 
G

Guest

Hi,

I suggest you use the next code:

Private Sub TextBox1_KeyUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles TextBox1.KeyUp
If (e.KeyCode = Keys.Tab) Then
MessageBox.Show("Tab Key")
End If
End Sub

With this code, you'll receive the feedback when the user has pushed the Tab
key and the focus has been received by the TextBox Control.

I hope that helps.

Kind regards,

Jorge Serrano Pérez
MVP VB.NET
 

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