Can anyone help please?
How can I give focus to a textbox (for example we have two) by defining a shortcut key as alt+m ?
Thanks in advance
Btw, I'm a beginner so please tell me in the simplest way. :)

Edited by Lida_pink: n/a

7 Years
Discussion Span
Last Post by Lida_pink

Use a Label in front of each text box and in the Caption for the Label, use an & in front of the letter to define the shortcut key - &m in your example. Make sure the Label's TabIndex is one less than the TabIndex for its associated TexBox. That should do it.


Well this doesn't work out. :(
Can anyone please help me out? I have an exam coming. :(


While, I would suggest using a menu with a key combination shortcut, the suggestion by SCBWV does work...

Start a new standard exe project and add in this order, text box (text1), label (label1), text box (text2). Now set the caption of the label to &Focus. You should see Focus in the labels caption. Now, just to make sure that the tab orders are correct, lets check.

Text1 TabIndex = 0
Label1 TabIndex = 1
Text2 TabIndex = 2

Run the program and press ALT+F. You should see the carat jump from text1 to text2.

Good Luck

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.