Solved

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

Posted on 2004-09-21
5
259 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
Comment Utility
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
Comment Utility
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
Comment Utility
this function seemed only supported by menu

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

Author Comment

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

Accepted Solution

by:
tzxie2000 earned 190 total points
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now