Link to home
Start Free TrialLog in
Avatar of sperodev
sperodev

asked on

How do I associate as specific label shortcut with a specific textbox?

Let's say I add 2 labels,  L&abel1 and La&bel2, to a form.  I then I add two textboxes,textBox1 and textBox2, to a form.
How do I get textBox1 to get the focus when I hit Alt-b, and textBox2 to get the focus when I hit Alt-a?
Avatar of tzxie2000
tzxie2000
Flag of China image

write this in your KeyDown Event

 If (e.Alt And e.KeyValue = "a") TextBox1.Focus();
 If (e.Alt And e.KeyValue = "b") TextBox2.Focus();
Avatar of sperodev
sperodev

ASKER

I guess I need to repose the question.

While that may solve the problem, I still don't understand how, if you take first plop down a label on a new form, and then a textbox, and then change the labels caption to incorporate a shortcut, you get the label-textbox shortcut association "for free". I've looked through the code of a form that was made this way, and I can't see where the textbox and label are associated. How does C# accomplish this association, and can I do it in a similar fashion programatically.?
this function seemed only supported by menu

if you want it you have to write some code;
C'mon experts, you can do it!
ASKER CERTIFIED SOLUTION
Avatar of tzxie2000
tzxie2000
Flag of China image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial