Capturing hot keys

  • Thread starter Thread starter John
  • Start date Start date
J

John

Hi

How can my main form capture key strokes and pass them to various controls
on the form?

Thanks

Regards
 
Hi

How can my main form capture key strokes and pass them to various controls
on the form?

Thanks

Regards

If I understand your question, then you can set the forms KeyPreview
property. This will allow your form to recieve all the keystrokes
before it is passed on to controls.
 
Hi

How can my main form capture key strokes and pass them to various controls
on the form?

Thanks

Regards

You can also assign with keydown event:
Example on a button:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.Windows.Forms.KeyEventArgs) Handles Button1.KeyDown
If e.KeyCode = Keys.<desired_key> Then
MsgBox("key pressed")
End If
End Sub
 
John said:
How can my main form capture key strokes and pass them to various controls
on the form?

In addition to the other replies, you may want to add a mainmenu component
to your form, create menu entries, and assign shortcuts to the menu items.
Some types of controls support specification of mnemonics by placing the "&"
character directly in front of the character which should serve as mnemonic
for the control.
 
Back
Top