Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2004-09-21
5
Medium Priority
?
272 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 570 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses
Course of the Month10 days, 9 hours left to enroll

885 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