Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Visual Basic
Expertise: Intermediate
Aug 20, 1997



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Access Keys with Labels

There is a very simple trick you can perform with labels and text boxes that will help users who like to use the keyboard instead of the mouse. Notice the underlines in the label controls. By pressing the Alt key in combination with any of the underlined keys, the cursor will jump to the text box next to this label. For example, pressing Alt-F will move to the text box next to First Name, and pressing Alt-C will move the cursor to the City text box. To make this happen, set a TabIndex property like this: Label Text Box Prompt Control Control First Name 0 1 Cust. Type 2 3 Last Name 4 5 Street 6 7 and so on.... Label controls cannot receive the focus. When VB detects that you have pressed an Alt-key combination that corresponds to a label, the focus is set to the next control in the tab order that can take the focus. Making the TabIndex property of the text box one greater than the label control will cause the text box to become active when the key combination for the label is pressed.
Paul D. Sheriff
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date