Problème avec KeyDown et KeyCode.
Bonjour, voici ci-dessous un extrait de mon code pour le button 1
Code:
1 2 3 4
|
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
niveau_en_cours()
End Sub |
Dans une textbox, j'ai crée des raccourcis claviers :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
Private Sub question_KeyDown(ByVal sender As Object, ByVal t As System.Windows.Forms.KeyEventArgs) Handles question.KeyDown
If t.KeyCode = Keys.F11 Then
question.Text = "EXAMINE"
End If
If t.KeyCode = Keys.F11 Then
question.Text = "PRENDS"
End If
If t.KeyCode = Keys.Up Then
question.Text = "NORD"
End If
If t.KeyCode = Keys.Down Then
question.Text = "SUD"
End If
If t.KeyCode = Keys.Left Then
question.Text = "GAUCHE"
End If
If t.KeyCode = Keys.Right Then
question.Text = "DROITE"
End If
End Sub |
J'ai ensuite voulu supprimer le bouton 1 pour le mettre en raccourcis clavier comme suit :
Code:
1 2 3 4 5 6 7 8 9 10
|
Private Sub question_KeyDown(ByVal sender As Object, ByVal t As System.Windows.Forms.KeyEventArgs) Handles question.KeyDown
If t.KeyCode = Keys.Enter Then
niveau_en_cours()
End If
If t.KeyCode = Keys.F11 Then
question.Text = "EXAMINE"
End If |
Et là, à ma grande surprise, ca ne fonctionne pas ! Donc, je résume, avec le bouton et le "Accept Command" tout se fait sans problème, mais à partir de la texte box où l'utilisateur tape son texte puis fait ENTER pour valider, ça ne fonctionne plus.
Quelqu'un pourrait-il m'expliquer pourquoi ?
Merci d'avance.