473,471 Members | 4,650 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Best method to hide/show a single tabPage in a Tab control?

Hello,

This is probably an easy one, but I have not been able to figure it out so
far. I have a tab control on a windows forms app. Depending on some
business logic, I need to hide/show some of the individual tabs.

The tab page has no "visible" property. The tabpage class has a "hide"
method, but this does not seem to make it disappear. I have been able to
remove them via something like this:

this.tabControl1.Controls.Remove( myTab );

...but then I'm not sure how to put it back.
Can someone clue me in on how to hide & show tab pages dynamically?
I must be missing something obvious.

thanks
Robb
Nov 22 '05 #1
9 4206
Hi Robb,

First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to know how to hide a tabpage
and show it again. If there is any misunderstanding, please feel free to
let me know.

The tabpage has Visible property, but for some known issue it was not shown
in the intellisense. Calling the Hide method does the same thing as setting
Visible to false; However, on the tabpage control, the Hide method hides
all the controls in the tabpage but leave the tabpage itself visible. This
is the designed behavior as you can see in the following KB article.

http://support.microsoft.com/?id=834616

If you need to hide the tabpage, you have to remove it from the
tabControl.TabPages collection. And add it back if you need to show it
again. The TabPages collection doens't have an Insert method. The page will
be added to the last of the collection. In this case, I suggest you remove
all the tabpages and re-add them by order.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 22 '05 #2
I was all over the Internet yesterday looking for this, too. I found some
complicated workarounds but nothing easy in my app.

I finally bought the tab control from www.softelvdm.com and it works just
fine.

For the project I'm working on, it was just faster.
Nov 22 '05 #3
Did you look here?
http://dotnetrix.co.uk/tabcontrols.html

My TabControlEX is free and would probably have done what you want.
http://dotnetrix.co.uk/controls.html

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
"John Davies" <Jo********@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.com...
I was all over the Internet yesterday looking for this, too. I found some
complicated workarounds but nothing easy in my app.

I finally bought the tab control from www.softelvdm.com and it works just
fine.

For the project I'm working on, it was just faster.

Nov 22 '05 #4
Rob

this.tabControl1.Remove( myTab );
this.tabContro1.Add(myTab);

However better is to remove them all and to create all the tabs in the order
you want.
(You don't remove the actual tabpage only the reference from the tabControl)
(for the removing you can than use one method with a foreach)

I hope this helps,

Cor
Nov 22 '05 #5
Mick,

Sorry I forever forget that site from you and can than not find it anymore,
while I want to recoment it.

I was lazy this time and I thought that the problem was slightly different.

I have now set it in my HKW system.
:-)

Cor
Nov 22 '05 #6
That's OK Cor.
I don't expect other people to recommend my site, but it's nice when they
do.

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
Nov 22 '05 #7
Thanks everyone for the replies.

In the end I built a method which wraps the remove/add calls and does what I
want. The signature of the method is:

private void showTab ( Control tabPage, bool tabVisible )

This allowed me to encapsulte the annoying need to always either 1) check
for the existence of the tab in the controls collection before adding it, or
2) remove the tab before adding it, since it might already be there. Also
would serve as a good place to remove them all and re-add them, if I decided
to go that far. So far I haven't needed to worry about the ordering, but if
that becomes an issue I'll take your advice.

Thanks again for all the quick replies.

-Robb
Nov 22 '05 #8
Mick-

I did find your site, but the word Beta at the top scared me off. I needed
someone to yell at if the tab didn't work - we're on a pretty tight deadline.

John
Nov 22 '05 #9
"John Davies" <Jo********@discussions.microsoft.com> wrote in message
news:D1**********************************@microsof t.com...
Mick-

I did find your site, but the word Beta at the top scared me off. I needed
someone to yell at if the tab didn't work - we're on a pretty tight
deadline.

John


I consider it Beta since I only test on WinXP. However, I have a lot of very
happy users and only occasionally do I get a report of some minor glitch
that is usually very easily rectified.

I don't think you'll find a better tabcontrol, but I may be slightly biased
;-)

--
Mick Doherty
http://dotnetrix.co.uk/nothing.html
Nov 22 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: TMB333 | last post by:
I've researched as much as I can on the issue, but I've not found any clearly defined statement that acknowledges that the Hide method for a TabPage object just doesn't do what it's supposed to do....
9
by: Robb Gilmore | last post by:
Hello, This is probably an easy one, but I have not been able to figure it out so far. I have a tab control on a windows forms app. Depending on some business logic, I need to hide/show some...
4
by: TMB333 | last post by:
I've researched as much as I can on the issue, but I've not found any clearly defined statement that acknowledges that the Hide method for a TabPage object just doesn't do what it's supposed to do....
0
by: xyz | last post by:
Hi, I have two tab control on two different pages. On one tabControl I need the tab headers. When I remove the tabpage from this tabControl and put it on another one I don't want to show the...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.