3
votes

I have app where I have multiple textboxes and I would like to do when the user is focused in one textbox when he presses TAB button on keyboard I would like to skip the focus into other textbox which I will set.

Is there any way to do that easily? I have 20 textboxes in this form and I need it to skip from textbox1 to textbox2 to textbox3....textbox20 when press the TAB key.

3
You can reorganize TabIndex or set TabStop = false on the controls you want to skip.King King

3 Answers

1
votes

Sounds like you're looking for the TabIndex property, which is an integer value you can assign to controls either in code or in the designer properties window:

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.tabindex.aspx

See also the TabStop property:

http://msdn.microsoft.com/en-us/library/system.windows.forms.control.tabstop.aspx

Example:

TextBox1.TabIndex = 2;
TextBox2.TabStop = false;
TextBox3.TabIndex = 99;

With focus on TextBox1, pressing tab will jump to TextBox3, then back to TextBox1, and obviously TextBox2 is skipped.

2
votes

First of all you have to set the tab index of each text box,

you can set either from the properties window (for each textbox ) or set by selecting the menu

view->Taborder.

you can set the tab index and by pressing the Tab key the control wil automatically transfer from 1 textbox to another.

0
votes

in c# every Control has a property called tabStop and tabIndex

setting the tabIndex one after the other will make that when you press tab from one one textBox you'll get focus on the other

if you want a control not to get focus when pressing tab, though i'm not sure u want, but your question isn't clear on that so i didn't want you to miss it, put true in tabStop