Tab Order

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a Windows Input Form with many textboxes. I open my Form1.cs [Design],
click View->Tab Order, and set the sequence of textboxes the cursor jumps to
as the user hits the tab key. This works great.

After entering the first text box, the user will know if he needs to enter
data in boxes 2-23, or if he can skip directly to box 24. Of course, I don't
want to make him tab through boxes 2-23 if he doesn't need to go through
those boxes.

My idea is to add a button and make it the second item in the tab order. The
event handler for the button jumps the cursor to item 24. If the user tabs to
the button and hits enter, the cursor jumps to item 24. If he tabs to the
button and just hits tab again, he goes to the second text box.

Any ideas what to write in the button event handler to just the cursor to
the 24th text box?

Thanks
 
Can you determine automatically whether he needs to enter data in boxes
2-23 without the button?

The usual solution is to set Enabled=false for all of the text boxes in
which he doesn't need to enter any data, then just let him tab to the
"next" text box, which will skip all of the disabled ones.

If you can determine, automatically, from what he entered in the first
text box, whether other text boxes should be disabled, you should be
able to do this in the first text box's TextChanged event handler. If
you don't want the other text boxes enabled / disabled as the user
types, only when he tries to leave the text box, then try the Validated
or Leave events for the text box.

If you really have to have the user choose (it's not based on what he
typed in the first text box), then I would suggest a check box or two
radio buttons: the user tabs onto the check box and then either checks
it or unchecks it (or chooses one radio button or the other), which
causes the relevant text boxes to be disabled / enabled.
 
24thTextBox.Focus();

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Hard work is a medication for which
there is no placebo.
 
Assuming that you really want to do it through the button mechanism,
then I would suggest that instead of inserting a button and writing
code as specified by Kevin (which would of course work), you make your
control (by deriving from a Button Control) which takes as a property
the control to focus. this way you can simply place the button on the
form and set its property through the designer.

So if you need to change the control which is to be focused next, you
simply have to change the property.

Also, of course this comes in handy also because you can reuse the
button anywhere else in the application (or even other applications).

- Vaibhav
http://www.nagarro.com
 
Hi Randy,

Thank you for posting.
You can use the following sentence in the event handler for the button's
Click event to set the cursor to the 24th textbox(assuming that the 24th
textbox's name is textBox24).

this.textBox24.Focus();

If you have any other concerns or need anything else, please feel free to
let me know.


Sincerely,
Linda Liu
Microsoft Online Community Support

====================================================
When responding to posts,please "Reply to Group" via
your newsreader so that others may learn and benefit
from your issue.
====================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top