473,320 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 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 20673
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: ZhangZQ | last post by:
Supposing I have a class "UserControl1 : System.Windows.Forms.UserControl" in an Assembly "UI.dll", now I create an Application project and want to use the "UserControl1" in another AppDomain, ...
1
by: Shawn | last post by:
Hi. When I create a new UserControl in Visual Studio it automatically declares it as "MustInherit". In order for me to call a method in my UserControl I have to remove the "MustInherit" part. Am I...
11
by: Crirus | last post by:
I need to derive the Windows.Forms.Control 2 times so I design a class like this Public Class BMControl Inherits System.Windows.Forms.UserControl Public Class MapControl Inherits BMControl
1
by: Peter Proost | last post by:
Hi group I've got a usercontrol containing a textbox and alongside the textbox there's a combobox. I draw this control on top of a grid. So when the user clicks certain columns in the grid the...
0
by: Mihaly | last post by:
I have an UserControl which contains 2 controls: 1 CheckBox and 1 DateTimePicker. I created a new DataGrigColumnStile whit thes UserControl and I put them into a DataGrid. If I use my UserControl...
1
by: Jon | last post by:
I am sure this has been covered before, but I'm not having luck finding much that's useful. I use a single web page that has several text inputs and other controls, including a couple of...
5
by: Blue | last post by:
We have a custom word processing type editor built with C# and .NET 2.0 and we need to support typing in languages other than English. I want to be able to use the Windows IME to enter in text...
10
by: Benton | last post by:
Hi there, I have a UserControl with a couple of textboxes and a couple of buttons ("Save" and "Cancel"). The Click event for this buttons is in the UserControl's codebehind of course, so here's...
0
by: =?Utf-8?B?UmljYXJkbyBGdXJ0YWRv?= | last post by:
I'm a vb programmer but i have to make a control in C# to be consumed by a vb .net application. I've found some help on the internet/newsgroups in order to scan an image from a twain source and...
1
by: xke | last post by:
I have a base class which overrides CreateChildControls / Render. Inside CreateChildControls, based on a public property ShowLinks in this class, I can include/display a usercontrol (kind of set of...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.