Form Shortcut Navigation

kermit5

Registered User.
Local time
Today, 20:19
Joined
Nov 2, 2001
Messages
122
I want to set up the feature where a character in the label of a field is underscored so that when I press alt-"letter" that field will get in focus. How do I do this?
 
Underline the character in the caption by putting an ampersand before the character you want underlined (i.e. My &Caption) will underline the "C" the caption "My Caption".

In the KeyDown event of the form place the following code:

Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)

If Shift + KeyCode = 71 Then

End Sub

txtItem.SetFocus

Where "txtItem" is the control you want to receive the focus. The If statement must evaluate to the Shift (in the case of "Alt" being pressed this equals 4) + the KeyCode (which is the ANSI value for the key pressed in conjunction with "Alt" - in the example above this would be 67 - the ANSI KeyCode for "C"). You must identify the ANSI value for the underlined character in your caption and set the If statement equal to 4 + this value.

The last thing you must do is set the KeyPreview property of the form to "Yes".
 

Users who are viewing this thread

Back
Top Bottom