472,119 Members | 1,613 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

Tab order between UserControl

Consider a Form that looks like:

[ a1 ] [ b1 ]
[ a2 ] [ b2 ]

a1 & a2 is a *custom* UserControl, as is b1 & b2.

How do you make the TAB order go from a1 -> b1 ?

Setting TabIndex doesnt work. Is there a "clean" way not using FocusLost
or similar?

Regards

--
Wal
http://www.vooose.com

*** Sent via Developersdex http://www.developersdex.com ***
Dec 19 '05 #1
7 20547
vooose wrote:
Consider a Form that looks like:

[ a1 ] [ b1 ]
[ a2 ] [ b2 ]

a1 & a2 is a *custom* UserControl, as is b1 & b2.

How do you make the TAB order go from a1 -> b1 ?

Setting TabIndex doesnt work. Is there a "clean" way not using FocusLost
or similar?

Regards

--
Wal
http://www.vooose.com

*** Sent via Developersdex http://www.developersdex.com ***


You mean that a1 and a2 belong to UserControl1, and b1 and b2 belong to
UserControl2, right?
Now you want to tab from a1 to b1 without first tabbing to a2?

When you set TabIndex, it works for all controls of the same parent, so
what you can do is:

// CODE
UserControl1.TabIndex = 0;
UserControl2.TabIndex = 1;

a2.TabIndex = 0;
a1.TabIndex = 1;

b1.TabIndex = 0;
b2.TabIndex = 1;

// END CODE

This way it will go from a1 to b1.

Hope it helps,
Andrey
Dec 19 '05 #2
Thanks for your reply. Did you mean

a1.TabIndex = 0;
a2.TabIndex = 1;

instead of

a2.TabIndex = 0;
a1.TabIndex = 1;

??

Either way it does not work. Can we clarify that you can NOT change the
tab index via the designer?? (this is what i experience) You must change
the tabindex as you indicated in-code as you can't access the a1, a2 etc
from the designer and therefore change their tab index

Regards

--
Wal
http://www.vooose.com

*** Sent via Developersdex http://www.developersdex.com ***
Dec 19 '05 #3
>When you set TabIndex, it works for all controls of the same >parent,
so what you can do is

They don't have the same parent. a1 and a2 sit in UserControl1 (parent A
lets say) and b1 and b2 are in UserControl2 (parent B lets say)

Is it perhaps impossible to tab between two controls of different
parents? (unless you are on the last control of one parent going to the
next control of the second parent, eg a2 -> b1)
--
Wal
http://www.vooose.com

*** Sent via Developersdex http://www.developersdex.com ***
Dec 19 '05 #4
vooose wrote:
When you set TabIndex, it works for all controls of the same >parent, so what you can do is

They don't have the same parent. a1 and a2 sit in UserControl1 (parent A
lets say) and b1 and b2 are in UserControl2 (parent B lets say)

Is it perhaps impossible to tab between two controls of different
parents? (unless you are on the last control of one parent going to the
next control of the second parent, eg a2 -> b1)


You are right, you go from last control of first parent to first control
of second parent, so if you set tab index of "a1" bigger than of "a2"
(that's why i put a1.Tabindex = 1; a2.TabIndex = 0;), it will work.

And yes you *can* set TabIndex thru designer - that's how i always set
it. Setting it in the code is hell of time waisting.

Or you can set a2.TabStop = false; this way it will not go to a2 using
Tab at all and will go from a1 to the next control right away.

Let me know if you need any more help here

MuZZy



--
Wal
http://www.vooose.com

*** Sent via Developersdex http://www.developersdex.com ***

Dec 19 '05 #5
>And yes you *can* set TabIndex thru designer - that's how i >always set
it. Setting it in the code is hell of time waisting

Something is wrong here, as I can't change the TabIndex of my fields
that sit in my custom control in the designer. (a1&a2, b1&b2). In fact
for any custom I've created i've been unable to do this.

If I have a form with two *panels* and drag two textboxes onto each
panel then yes, I can change the tab index on the designer - but NOT
when adding custom controls. How are you doing this?

Regards

--
Wal
http://www.vooose.com

*** Sent via Developersdex http://www.developersdex.com ***
Dec 19 '05 #6
Ok ignore the above - I figured out what I was doing wrong (not worth
explaining but a1, a2 etc are not plain text boxes).

Thanks for that! Now I am going from a1 -> b1. Now here's another
one...what if now I want b1 - > a2??

The final tab-order needs to be a1 -> b1 -> a2 -> b2

I don't think using TabIndex you can make b1 go back to a2...

Regards

--
Wal
http://www.vooose.com

*** Sent via Developersdex http://www.developersdex.com ***
Dec 19 '05 #7
vooose wrote:
Ok ignore the above - I figured out what I was doing wrong (not worth
explaining but a1, a2 etc are not plain text boxes).

Thanks for that! Now I am going from a1 -> b1. Now here's another
one...what if now I want b1 - > a2??

The final tab-order needs to be a1 -> b1 -> a2 -> b2

I don't think using TabIndex you can make b1 go back to a2...


Right, you can't do that - you'll need to do some coding here. For
example you can toggle TabIndex of a1, a2 and b1, b2 - programmatically.

Regards,
MuZZy
Dec 20 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Shawn | last post: by
1 post views Thread by Peter Proost | last post: by
reply views Thread by Mihaly | last post: by
1 post views Thread by Jon | last post: by
reply views Thread by =?Utf-8?B?UmljYXJkbyBGdXJ0YWRv?= | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.