NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Creating Access Keys with Label Controls

Win Forms Label controls can be used to define keyboard shortcuts for other controls. When you define an access key in a label control, the user can press the ALT key plus the character you designate to move the focus to the control that follows it in the tab order. Because labels can't receive focus, focus automatically moves to the next control in the tab order. Use this technique to assign access keys to text boxes, picture boxes, combo boxes, list boxes, and data grids.

To assign an access key to a control with a label

  1. Add the controls in any order to your class and set the TabIndex property of the label to one less than the control you want to assign an access key to.
  2. Set the label’s UseMnemonic property to true.
  3. Use an ampersand in the label's Text property to assign the access key for the label. For more information, see Creating Keyboard Shortcuts for Controls.
    Note   You may want to display ampersands in a label control, rather than use them to create access keys. This may occur if you bind a label control to a field in a recordset where the data includes ampersands. To display ampersands in a label control, set the UseMnemonic property to false.

See Also

Label Class | Sizing a Label Control to Fit Its Contents | Label Control