Click here to Skip to main content
15,891,908 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have form with two TEXTBOX: txtb1 and txtb2.
whith the following function I change the focus between the buttons. when I press ALT+1 the txtb1 TEXTBOX get the focus and when I press ALT+2 the
focus go to txtb2 TEXTBOX.

I first need to set the keypreview of the form to true.

VB
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
        If Control.ModifierKeys = Keys.Alt Then
            If e.KeyCode = Keys.D1 Then
                TextBox1.Focus()
            ElseIf e.KeyCode = Keys.D2 Then
                TextBox2.Focus()
            End If
        End If
    End Sub



this function doesn't work if the form have a menustrip.
are there option to disable the alt in the menustrip?
Posted
Updated 24-Nov-11 6:23am
v3

1 solution

No, all windows forms uses this behavior, try to use another key or a cambination.
Ctrl+Alt+1 or Ctrl+1
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900