Assign a hotkey to button control

  • Thread starter Thread starter Bill Nguyen
  • Start date Start date
B

Bill Nguyen

I would like a assign a Function key (F8, for example) to invoke a button
control click
Please help!

Thanks

Bill
 
Bill Nguyen said:
I would like a assign a Function key (F8, for example) to invoke a
button control click
Please help!


Set the Form's keypreview property to true. In the Form's KeyDown event,
catch the key and call the same procedure as you call in the button's click
event. Or, if the Form has a Menu, add the function as a menu item and
assign F8 as the shortcut. In the click event, invoke the code.


Armin
 
Armin Zingler said:
Set the Form's keypreview property to true. In the Form's KeyDown event,
catch the key and call the same procedure as you call in the button's
click
event. Or, if the Form has a Menu, add the function as a menu item and
assign F8 as the shortcut. In the click event, invoke the code.

Note that if you are using the standard menu control (not the toolstrip) the
menu item doesn't even need to be visible in order to make the shortcut
work.
 
Standard practice is to use & in button text(caption) before some letter.
Then Alt-<letter> works as hot key without any further ado

HTH
 

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.

Ask a Question

Similar Threads


Back
Top