Solved

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

Posted on 2004-09-21
5
265 Views
Last Modified: 2008-02-26
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?
0
Comment
Question by:sperodev
  • 3
  • 2
5 Comments
 
LVL 5

Expert Comment

by:tzxie2000
ID: 12117697
write this in your KeyDown Event

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

Author Comment

by:sperodev
ID: 12117912
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.?
0
 
LVL 5

Expert Comment

by:tzxie2000
ID: 12117984
this function seemed only supported by menu

if you want it you have to write some code;
0
 

Author Comment

by:sperodev
ID: 12118196
C'mon experts, you can do it!
0
 
LVL 5

Accepted Solution

by:
tzxie2000 earned 190 total points
ID: 12118398
set label1.tabindex=1
set textbox1.tabindex=2
set label1.tabindex=3
set textbox1.tabindex=4
you can get it

the most important is not the number assigned to tabindex

the msdn said that when you Press alt-a(suggest in l&abel),the focus will set to the controls tabindex next to the label
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question