Rachael
Rachael

Reputation: 1993

Keyboard Shortcuts in VB.NET

I want a Ctrl+V hotkey shortcut in my form. I've tried some variants of the following, with no luck:

Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
    If e.KeyCode = Keys.V And e.Control = True Then
        TextBox1.Text = "AUTO"
    End If
End Sub

Thanks in Advance!

Upvotes: 0

Views: 81

Answers (1)

Bradley Uffner
Bradley Uffner

Reputation: 16991

Have you set KeyPreview on the form to True? Otherwise the control that has focus will eat the event before the form has a chance to see it.

Upvotes: 1

Related Questions