Detecting Tab Key

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How do I determine if the user has pressed the tab key? The Keypress and Keydown events fire for other keys, but not the tab.
 
* "=?Utf-8?B?Q2hhcmxpZQ==?= said:
How do I determine if the user has pressed the tab key? The Keypress
and Keydown events fire for other keys, but not the tab.

\\\
Protected Overrides Function ProcessDialogKey(ByVal keyData As System.Windows.Forms.Keys) As Boolean
If keyData = Keys.Tab Then
MsgBox("Pressed")
End If
MyBase.ProcessDialogKey(keyData)
End Function
///
 
Hi Charlie,

If you set the form's keypreview property to true, you will trap the tab key
in the keyup event of the form.

HTH,

Bernie Yaeger

Charlie said:
How do I determine if the user has pressed the tab key? The Keypress and
Keydown events fire for other keys, but not the tab.
 
Bernie,

* "Bernie Yaeger said:
If you set the form's keypreview property to true, you will trap the tab key
in the keyup event of the form.

Only if there are no controls on the form, all controls are disabled or
the controls don't have tabstops.
 
Hi Herfried,

No, I tested it on a form with controls, some of which were tabstops and not
disabled.

Bernie
 
Back
Top