Jerold, the usual way to do this in the Windows is to use underlined letters in the labels. These labels could be accessed quickly using ALT+<letter>, where letter is one of the underlined letters in labels.
Do following:
Use '\<' in the caption of label to underline letter in the caption. For example, you have textbox and label 'Name'. You assign caption for label '\<Name', so it will look like Name.
Rearrange tab order of controls so label that belongs to control will have tab order before tab order of control. For example, label 'Name' should have tab order 2 when textbox for name enterng have tab order 3.
Of course, you can use 'ON KEY LABEL' command to assign any command to the certain keys. Of course, you can use 'KeyPreview' property of form and than write code in 'KeyPress' event of form to trap certain keys and change focus. However, it is not usual way for Windows and used in situations when you have no other choise.
If I understand you, Jerold, you want some hot key that moves you out of the grid on onto the next control in the tab order.
You might try the Form.Keypress event, and have it trap for a certain key or key combination, then set the focus to the desired control if that key has been pressed.
Using keypress, the parameter nKeyCode holds the keycode and the parameter nShiftAltCtrl holds a value indicating if <Shift>, <Alt> or <Ctrl> was held down:
<Shift> = 1, 0001 (bin)
<Alt> = 2, 0010 (bin)
<Ctrl> = 4, 0100 (bin)
(see also the MSDN lib.)
Pressing <Shift>+<Ctrl>+<a> would result in:
nKeyCode : 97
nShiftAltCtrl: 5 (1 + 4)
There is a catch: the keypress event doesn't fire for <Alt>-combinations..... )o:
The only solution I've come up with sofar for trapping <Alt>-combinations is using the Microsoft Forms 2.0 textbox ActiveX, as this control traps all keypresses, but this solution doesn't work in combination with the forms' keypress-event.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.