Hot key labels
By: Lorenzo Dalla Vecchia Date: 19/10/1998

Here's how to create a label, with a hot key associated, that set the focus on a control. For example you can create a form with two labels and two textboxes next to them.

To give a hot key to a label, use a & (ampersand) in its caption before a letter. For example the caption &Name will have the ALT+N hot key and the caption A&ddress will have the ALT+D hot key. The letters N and d will be underlined to show they are "hot".

Now that we have set up the hot key, by chosing it the label will get the focus. But, because a label can't hold the focus, the label will pass it to another control (i.e. a textbox). How to set that control? Simply give to its TabStop property the value next the one of the label. For example: to make the label lblName pass focus to the textbox txtName, set up these properties:

lblName.TabStop = 0
txtName.TabStop = 1

By pressing ALT+N the focus will go to txtName.

Click Here!

Visual Basic Programming Zone is a website by Lorenzo Dalla Vecchia.
To contact the Webmaster, click here.
Hosted by InWind: