Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what could be the possible reasons for TabIndex not working properly

Tags:

c#

winforms

so I have started from 0 and defining tabindex for the controls on my form but at run time it is all messed up. the form is a little complex tho. it has horizontal and vertical splitters and panels, group boxes and some older VB 6.0 activeX controls which is a Tree control inside them. even if i do it programmatically and read previewkeydown eventg and say if it is TAB then control2.Focus() it is still working wrong. so frustrating. any thoughts? ..there are also labels on the form which do not need tab so I have defined 0 for their index.

like image 793
Bohn Avatar asked May 26 '11 13:05

Bohn


2 Answers

The reason is that the controls are in different Containers. Suppose you've got panel1.TabIndex = 0 and panel2.TabIndex = 1, then in panel2, textBox1.TabIndex = 0, in panel1, textBox2.TabIndex = 1. At runtime, textBox1 comes before textBox2 because its panel comes first!

As kerry said, use view->tab order to see the complete hierarchy of tab orders.

like image 87
Alireza Avatar answered Oct 23 '22 02:10

Alireza


How are you setting it? If you are in visual studio with the form in design view select view -> tab order and then click on each item in the order you want them.

Usually works for me.

like image 23
kerry Avatar answered Oct 23 '22 02:10

kerry