Set the form's 'KeyPreview' property to 'True', then add this code to your
form (assuming the form's class name is 'Form1'):
\\\
Private Sub Form1_KeyDown( _
ByVal sender As Object, _
ByVal e As System.Windows.Forms.KeyEventArgs _
) Handles MyBase.KeyDown
If e.KeyCode = Keys.F2 Then
MsgBox("F2 pressed!")
End If
End Sub
///
One,
In addition to overriding the KeyDown event, if you have a Menu on your form
you can assign the function keys to a MenuItem.
Remember: You can assign the function keys to a MenuItem that has its
Visible property set to false, and it will still work!
See the Shortcut property of a MenuItem, along with the Visible property if
needed.
Then you can simply handle the Click event for the MenuItem.
Hope this helps
Jay
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.