Hi

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

Thanks

Regards

Re: Capturing hot keys by Tom

Tom
Mon Feb 18 23:20:12 CST 2008

On Feb 18, 2:49=A0pm, "John" <J...@nospam.infovis.co.uk> wrote:
> 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.

--
Tom Shelton

Re: Capturing hot keys by kimiraikkonen

kimiraikkonen
Tue Feb 19 04:40:13 CST 2008

On Feb 18, 11:49 pm, "John" <J...@nospam.infovis.co.uk> wrote:
> 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

Re: Capturing hot keys by Herfried

Herfried
Tue Feb 19 21:03:31 CST 2008

"John" <John@nospam.infovis.co.uk> schrieb:
> 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.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>