TabIndex property not working for me

M

michael sorens

I have a form with a variety of controls (TextBox, CheckBox, and Button).
I have assigned TabIndex values starting from 1 at the top, working my way
down the form to 15 at the bottom. Each of these has TabStop set to true.
When I run the application and repeatedly press the tab key, the on-screen
focus order is very different than what I thought I specified. If it
matters, here is the general layout of my form. As you'll observer, most
of the controls are within separate Panels, except for the main ok and
cancel buttons which are outside the TabControl. What am I doing wrong?

Form
TabControl
TabPage
TableLayoutPanel
Panel
Label
TextBox
Panel
Label
TextBox
Panel
CheckBox
TextBox
Panel
Label
TextBox
Panel
Label
TextBox
okButton
cancelButton
 
L

Linda Liu [MSFT]

Hi Michael,
Thank you for posting. From your post, my understanding on this issue is:
When you run your application and press the Tab key repeatedly, you can not
get proper focus order on your form. If I¡¯m off base, feel free to let me
know.
Since some controls such as Label TextBox are put into a Panel in your
project, the Panel¡¯s TabIndex property should be set properly first. For
example, there are four Panels on your form and each Panel contains several
controls. To get proper focus order, the four Panels¡¯ TabIndex properties
should be set to sequent numbers and the TabIndex properties of the
controls in one Panel should be set to sequent numbers too.
Please let me know if you have any other concerns, or need anything else.

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.
====================================================
 
M

michael sorens

Thank you for the response. Working from your input, I now understood how
TabIndex properties nest with the nesting of components. (This is not at
all clear in the documentation.) So top level components must be numbered
0, 1, 2, etc. Then within those components, one starts renumbering again
from 0. So one might end up with, for example:
0.0, 0.1, 0.2, 1, 2.0, 2.1, 3, 4.0, 4.1, 5.0, 5.1, 5.1.1, 5.1.2, 5.2,
5.3
When the user tabs through a form, these numbers are simply consumed from
lowest to highest. Thus, since 4.1 is smaller than 5.0, the control at 4.1
will be reached before the one at 5.0.
 
L

Linda Liu [MSFT]

Hi Michael,
I am glad to heart that the problem has been fixed. If you have any other
questions or concerns, please do not hesitate to contact us. It is always
our pleasure to be of assistance.
Have a nice day!



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.
====================================================
 
L

lokhande.praveen

The TabIndex property is of type int and not float/double. How would
one indexes of nested component to say 0.0., 0.1 etc.
 
J

Jon Skeet [C# MVP]

The TabIndex property is of type int and not float/double. How would
one indexes of nested component to say 0.0., 0.1 etc.

I think the point is that the top-level component has index 0, then the
components within it have 0 and 1 to get effective indexes of 0.0 and
0.1, etc.
 

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

Top