473,386 Members | 1,785 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,386 software developers and data experts.

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 4200
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.