|
|
Title | Convert Up and Down arrow keys to Tab and Shift-Tab for easy navigation in Visual Basic .NET |
Description | This example shows how to convert Up and Down arrow keys to Tab and Shift-Tab for easy navigation in Visual Basic .NET. |
Keywords | Tab, Tab key, up arrow, down arrow, navigation |
Categories | Miscellany, Software Engineering |
|
|
Set the form's KeyPreview property to True, either at design time or in the form's Load event handler as shown here.
In the form's KeyDown event handler, look for the Up and Down arrow keys. When you see one of these, call ProcessTabKey to simulate a Tab or Shift-Tab and set e.Handled to True so the form doesn't process the arrow key further.
|
|
Private Sub Form1_Load(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles MyBase.Load
Me.KeyPreview = True
End Sub
' If we see an up or down arrow key,
' process a tab or shift-tab key instead.
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e _
As System.Windows.Forms.KeyEventArgs) Handles _
MyBase.KeyDown
If e.KeyCode = Keys.Up Then
Me.ProcessTabKey(False)
e.Handled = True
ElseIf e.KeyCode = Keys.Down Then
Me.ProcessTabKey(True)
e.Handled = True
End If
End Sub
|
|
|
|
|
|