Using Keys on Command Button

  • Thread starter Thread starter Roger Bell
  • Start date Start date
R

Roger Bell

Is there a way that a key can be assigned to a command button, instead of
clicking the button with the mouse?

Thanks for any help
 
Is there a way that a key can be assigned to a command button, instead of
clicking the button with the mouse?

Thanks for any help

Yes, two ways: by default you can *tab* to a control button (if its Tab Stop
property is set to Yes, which it ordinarily will be) and press the spacebar;
or you can put an ampersand & in front of a letter in its Caption to make that
letter a hotkey. For instance, if the Caption of the button is E&xit, the user
will see the X underlined, and pressing alt-X will press the button.
 
Many thanks for that John,

Is there any way you can do similar with a combo box?

Thanks again
 
Many thanks for that John,

Is there any way you can do similar with a combo box?

Not sure what you mean, Roger! If you leave the default Auto Complete property
of the combo box set, then you can tab to the combo; type a letter, and it
will jump to the first row which starts with that letter. Type another letter
and it will jump to the first row with that as the second letter - e.g. if you
type <tab> R O B into a names combo box, it will jump right to Robinson if
that's the first name starting with those letters.
 
Sorry, John for not making myself clearer. I know that you can Tab or click
on the down arrow to access the list.

I just wondered if you can create a keyboard combination to move the cursor
to that field.

Thanks again
 
Sorry, John for not making myself clearer. I know that you can Tab or click
on the down arrow to access the list.

I just wondered if you can create a keyboard combination to move the cursor
to that field.

I've never tried it, but you should be able to put a command button (or even a
label) by the combo box, with a hotkey (the ampersand in the caption trick);
in its Click event you could setfocus to the combo. Not sure how much easier
that makes it though!
 
Back
Top