Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2004-09-21
5
264 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 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