468,738 Members | 2,422 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,738 developers. It's quick & easy.

Hiding a TabPage???

(posted this in VB group but then realized I probably should have posted here)

I have a TabControl with several TabPages. Upon startup, I only want to
show the first TabPage, hiding the rest. Then once the user does some things,
I will show the other TabPages.

I have tried by putting TabPage2.Hide() in the Form_Load event, but no luck.
I put the same in a button to see if it was a timing issue with loading.
Still nothing.

What am I missing here??

Thanks!!
Nov 22 '05 #1
4 2210
In article <D9**********************************@microsoft.co m>,
St*********@discussions.microsoft.com says...
(posted this in VB group but then realized I probably should have posted here)

I have a TabControl with several TabPages. Upon startup, I only want to
show the first TabPage, hiding the rest. Then once the user does some things,
I will show the other TabPages.

I have tried by putting TabPage2.Hide() in the Form_Load event, but no luck.
I put the same in a button to see if it was a timing issue with loading.
Still nothing.

What am I missing here??


The current Tab control doesn't support hiding/unhiding of individual
tag pages. Instead, you'll need to remove/add the tab pages dynamically
at run time.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele
Nov 22 '05 #2
Wow. That seems like something basic that would be there. I've been doing it
in Delphi for some years now. But that is neither here nor there.

I would assume that I would have to dynamically create all the controls on
the form too.

Could I have a tabcontrol with the hidden pages on it, with the entire
control hidden, and then just move them (change the parent, or something) to
the tabcontrol that is visible?

Any pointers would be much appreciated.
"Patrick Steele [MVP]" wrote:
In article <D9**********************************@microsoft.co m>,
St*********@discussions.microsoft.com says...
(posted this in VB group but then realized I probably should have posted here)

I have a TabControl with several TabPages. Upon startup, I only want to
show the first TabPage, hiding the rest. Then once the user does some things,
I will show the other TabPages.

I have tried by putting TabPage2.Hide() in the Form_Load event, but no luck.
I put the same in a button to see if it was a timing issue with loading.
Still nothing.

What am I missing here??


The current Tab control doesn't support hiding/unhiding of individual
tag pages. Instead, you'll need to remove/add the tab pages dynamically
at run time.

--
Patrick Steele
Microsoft .NET MVP
http://weblogs.asp.net/psteele

Nov 22 '05 #3
Stress Puppy,

That is not so strange that you do it in Delphi already many years, when I
see an application with Tabpages I always start to assume that it is written
with Delphi, it seems always for me if there are no other applications made
with Delphi than with tabpages at the right and a treeview on the left side.

However the dotNet tabcontrol has a bug at the moment (What means for me
because almost everybody knows this one that there are not so many bugs).

To resolve that bug is the simple solution to make a simple loop wherein you
remove and add the pages when you need that from the tabcontrol. It is not
removing the pages or creating them new. It is only removing and setting the
reference in the tabcontrol so not a real performance consuming operation.

I hope that this gives an idea.

Cor
Nov 22 '05 #4
Hiding a control is the same as setting it's Visible property to false. When
a tabpage is not selected it is not visible. This is why the Hide/Visible
methods do not work as you expect.

I would just have the one tabcontrol, and when I have finished adding and
designing tabpages, I would remove the tabpages from the tabcontrol by
removing the "TabControl.Controls.Add(TabPageX)" lines in
InitializeComponent(). Then, at runtime, add tabpages to the tabcontrol as
they become available for user interaction.

Instead of editing the InitializeComponent() code, you may wish to clear the
tabpages and then add the first tabpage, in the forms load method. This way
all tabpages are always available for editing at designtime.

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

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by StressPuppy | last post: by
1 post views Thread by Paul Sampson | last post: by
1 post views Thread by Dmitry Karneyev | last post: by
8 posts views Thread by touf | last post: by
2 posts views Thread by RSH | last post: by
5 posts views Thread by marfi95 | last post: by
6 posts views Thread by ray well | last post: by
6 posts views Thread by =?Utf-8?B?U2hhcm9u?= | last post: by
1 post views Thread by CARIGAR | last post: by
xarzu
2 posts views Thread by xarzu | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.