John Nuñez
John Nuñez

Reputation: 1830

Detect Event in any control into the FORM VB.NET

just now I was trying to capture the F1 key on the form, but only managed when the form is selected, and I need to detect it in any form control

I used this code:

Select Case e.KeyCode
    Case Keys.F1
        MsgBox("Right")
        e.Handled = True
End Select

Upvotes: 0

Views: 309

Answers (1)

KV Prajapati
KV Prajapati

Reputation: 94653

You need to set Form.KeyPreview=True - If it is true then form will receive all key events.

Upvotes: 2

Related Questions