TabControl - shifting tabIndex IDs doesn't work
Messages   Related Types
This message was discovered on ASPFriends.com 'winforms-cs' list.


Jeff Woodie
I'm pulling my hair out over this one. Seems like a bug, but I'm hoping for
a workaround.

I've got a TabControl that has 7 tabs. Depending on the type of form I'm
displaying, I hide 2 of these tabs all the time, so there's always 5 visible
tabs at run-time. I noticed today that the wrong tabs were getting hidden,
so I started digging. Turns out, my TabIndexes were out of sync with what
they had been for the past week. I used the TabCollection dialog box (from
the Properties window) to move the tabs around, sometimes this had an
effect, sometimes not. I used the code editor to manually re-arrange the
TabIndexes back to what the should be, and that didn't seem to have an
effect at all. Basically, no matter which method I use at this point, my
tabs end up in the wrong positions. This is especially important because I
need those Indexes to remain constant for the tabs I want to hide, so I
don't hide the wrong ones.

Anybody else have this problem? I searched the archive and didn't find
anything similar, but any suggestions for a work-around would be very
helpful.

Thanks,

Jeff Woodie

Reply to this message...
 
    
Stephen Rees

Don't know.

But I do know don't mess about with the code made by the Forms Designer.
It'll just rewrite it.

If you need to alter stuff then do it after the form has loaded, and after
InitializeComponents() in the constructor. Try rearranging the tabs here.

Maybe you have a little green man in your computer that only comes out a
night, and is determined to have your tabs his way round ?

:-)
Steve.

-----Original Message-----
From: Jeff Woodie [mailto:Click here to reveal e-mail address]
Sent: 14 June 2002 23:51
To: winforms-cs
Subject: [winforms-cs] TabControl - shifting tabIndex IDs doesn't work

I'm pulling my hair out over this one. Seems like a bug, but I'm hoping for
a workaround.

I've got a TabControl that has 7 tabs. Depending on the type of form I'm
displaying, I hide 2 of these tabs all the time, so there's always 5 visible
tabs at run-time. I noticed today that the wrong tabs were getting hidden,
so I started digging. Turns out, my TabIndexes were out of sync with what
they had been for the past week. I used the TabCollection dialog box (from
the Properties window) to move the tabs around, sometimes this had an
effect, sometimes not. I used the code editor to manually re-arrange the
TabIndexes back to what the should be, and that didn't seem to have an
effect at all. Basically, no matter which method I use at this point, my
tabs end up in the wrong positions. This is especially important because I
need those Indexes to remain constant for the tabs I want to hide, so I
don't hide the wrong ones.

Anybody else have this problem? I searched the archive and didn't find
anything similar, but any suggestions for a work-around would be very
helpful.

Thanks,

Jeff Woodie

| [winforms-cs] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/winforms-cs.asp = JOIN/QUIT

Reply to this message...
 
    
Casey, Michael
Jeff,

I'm not familiar with this specific situation, but based upon your
description I would look at the order in which the tab pages are added to
the Tab Control's collection. You talked about re-arranging pages in the
designer, but I'm not sure whether that involved deleting and re-adding.

Look into the InitializeComponent() method to see if the order of the pages
coincides with the order in which they are added to the collection. If this
is the case, then perhaps this could be the cause?

In general you should not edit code in this method, because subsequent use
of the designer can eradicate your changes, but you can fiddle with the code
to study the effects.

Mike Casey

-----Original Message-----
From: Jeff Woodie [mailto:Click here to reveal e-mail address]
Sent: Friday, June 14, 2002 6:51 PM
To: winforms-cs
Subject: [winforms-cs] TabControl - shifting tabIndex IDs doesn't work

I'm pulling my hair out over this one. Seems like a bug, but I'm hoping for
a workaround.

I've got a TabControl that has 7 tabs. Depending on the type of form I'm
displaying, I hide 2 of these tabs all the time, so there's always 5 visible
tabs at run-time. I noticed today that the wrong tabs were getting hidden,
so I started digging. Turns out, my TabIndexes were out of sync with what
they had been for the past week. I used the TabCollection dialog box (from
the Properties window) to move the tabs around, sometimes this had an
effect, sometimes not. I used the code editor to manually re-arrange the
TabIndexes back to what the should be, and that didn't seem to have an
effect at all. Basically, no matter which method I use at this point, my
tabs end up in the wrong positions. This is especially important because I
need those Indexes to remain constant for the tabs I want to hide, so I
don't hide the wrong ones.

Anybody else have this problem? I searched the archive and didn't find
anything similar, but any suggestions for a work-around would be very
helpful.

Thanks,

Jeff Woodie

| [winforms-cs] member Click here to reveal e-mail address = YOUR ID
| http://www.asplists.com/asplists/winforms-cs.asp = JOIN/QUIT

Reply to this message...
 
    
Erik Brown
Jeff,

Did you find a good solution to this problem. I've started seeing
this in an application as well. The Index entries assigned by Visual
Studio appear to be ignored, and the order in which the tabs are
inserted into the parent TabControl control matches how they appear in
the running application. I have modified things a few different ways
but so far the tab order has been mixed up each time (not always right
away, sometimes it takes a couple runs for Visual Studio to juggle the
order).

Is it something to do with the number of tabs displayed? I have about
7 or 8 tabs in my form. Nothing fancy. Just a dialog with a tab
control and buttons at the bottom.

I recall there was a response to your post, but I don't remember a
definitive solution.

Thanks,

Erik
========
Erik Brown
Author of "Windows Forms Programming with C#"
http://www.amazon.com/exec/obidos/ASIN/1930110286

[Original message clipped]

Reply to this message...
 
    
Troy Magner
Sometimes the designer appears to reorder tabs for me. I don't mess with teh designer code but sometimes I will open the designer for the form and see that the tabs have changed places. I was curious if anyone else has had this happen.

I don't like refering to the index of a particular tab simply because I don't want to mess with the code again if for some reason tabs are moved around, removed, added, etc. I like to refer to another property that is mush less likely to change such as the name of the TabControl. Plus it is much easier to identify which tab I am refering to in the code. Where as trying to remember which index is for which tab can be a pain.

Private Sub TabControl_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControl.SelectedIndexChanged
Select Case TabControl.SelectedTab.Name
Case TabPage1.Name
'Do things when TabPage1 is selected
Case TabPage2.Name
'Do things when TabPage2 is selected
Case TabPage3.Name
'Do things when TabPage3 is selected
Case TabPage4.Name
'Do things when TabPage4 is selected
End Select
End Sub

--------------------------------
From: Troy Magner
Reply to this message...
 
    
David Meachin
I agree that it's better to use named TabPage controls. I'm using Visual C++ .NET and have seen the same "feature", where the designer occasionally reorders the tab pages for no reason that I can figure out.
I have found that Visual Studio becomes unstable beyond a certain critical number of controls and methods, or maybe that's just because I'm using it with Oracle controls.

--------------------------------
From: David Meachin
Reply to this message...
 
 
System.EventArgs
System.Windows.Forms.TabControl
System.Windows.Forms.TabPage




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com