Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleConvert Up and Down arrow keys to Tab and Shift-Tab for easy navigation in Visual Basic .NET
DescriptionThis example shows how to convert Up and Down arrow keys to Tab and Shift-Tab for easy navigation in Visual Basic .NET.
KeywordsTab, Tab key, up arrow, down arrow, navigation
CategoriesMiscellany, 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
 
 
Copyright © 1997-2006 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated