Hide a TabPage 
Author Message
 Hide a TabPage

Lo,
I'd like to be able to hide a TabPage in a TabControl. But there's no
Visible propriety, how could i do that ?
Thanks


Tue, 14 Dec 2004 03:40:48 GMT  
 Hide a TabPage


Wed, 18 Jun 1902 08:00:00 GMT  
 Hide a TabPage

Quote:
Greetings. {*filter*}iK writes:
>I'd like to be able to hide a TabPage in a TabControl.
>But there's no Visible propriety, how could i do that ?

I was going to say just remove the page then re-add it
if you need to make it "visible" again. But in testing
this out I found that you can't close the window unless
you re-add the tabpage!

I made a simple two-page Tab Control with a "remove me"
button on one page and a "add page" button on the
other. I removed the remove me page trying to simulate
your visible property wish. This worked just fine except
when trying to Close the window during the state where
the page is removed.

Huh?

                           -Yamo-



Tue, 14 Dec 2004 04:51:04 GMT  
 Hide a TabPage
Greetings. Uh, I found out from an old thread
(search on "can't close") that Panels and things
that inherit from Panels like TabPages have this
bug that if you remove or clear them you can't
close the form. You have to Dispose the TabPage
before removing. (I'm using the first release
version of VS and haven't updated so this bug
may be fixed in the latest?)

Of course, now, for your original question you
would have to Dispose, then Remove to make
not visible and completely reinstantiate to
re-add the page. or catch close and clean up
with the pages yourself. Kinda yucky.

Sorry I couldn't be of more help...

                         -Yamo-



Tue, 14 Dec 2004 05:16:36 GMT  
 Hide a TabPage
Really thanks i'll see if the bug has persisted but i find it is a bit
stupid that there's no Hide() or Visible propriety, don't you think ?


Quote:
> Greetings. Uh, I found out from an old thread
> (search on "can't close") that Panels and things
> that inherit from Panels like TabPages have this
> bug that if you remove or clear them you can't
> close the form. You have to Dispose the TabPage
> before removing. (I'm using the first release
> version of VS and haven't updated so this bug
> may be fixed in the latest?)

> Of course, now, for your original question you
> would have to Dispose, then Remove to make
> not visible and completely reinstantiate to
> re-add the page. or catch close and clean up
> with the pages yourself. Kinda yucky.

> Sorry I couldn't be of more help...

>                          -Yamo-



Tue, 14 Dec 2004 17:16:28 GMT  
 Hide a TabPage
But.. i'm new at C# programming and .. I speak not very good english so I
will try to ask you how i can ;) :
if i have to remove the control to hide it, and reinstencie to redraw it,
does it mean I have to re-define all the proproeties of the TabPage ?? All
the controls that are in the tabpage have to be re-set for each reinstence
?? If it is true, it means I must copy the code generated by the VS form
designer in a personal function that will reput all the controls for each
instence, no ? . Thanks in advance


Quote:
> Really thanks i'll see if the bug has persisted but i find it is a bit
> stupid that there's no Hide() or Visible propriety, don't you think ?


> > Greetings. Uh, I found out from an old thread
> > (search on "can't close") that Panels and things
> > that inherit from Panels like TabPages have this
> > bug that if you remove or clear them you can't
> > close the form. You have to Dispose the TabPage
> > before removing. (I'm using the first release
> > version of VS and haven't updated so this bug
> > may be fixed in the latest?)

> > Of course, now, for your original question you
> > would have to Dispose, then Remove to make
> > not visible and completely reinstantiate to
> > re-add the page. or catch close and clean up
> > with the pages yourself. Kinda yucky.

> > Sorry I couldn't be of more help...

> >                          -Yamo-



Tue, 14 Dec 2004 17:42:47 GMT  
 Hide a TabPage
It's okay i've unterstood how to do it thanks !


Quote:
> But.. i'm new at C# programming and .. I speak not very good english so I
> will try to ask you how i can ;) :
> if i have to remove the control to hide it, and reinstencie to redraw it,
> does it mean I have to re-define all the proproeties of the TabPage ?? All
> the controls that are in the tabpage have to be re-set for each reinstence
> ?? If it is true, it means I must copy the code generated by the VS form
> designer in a personal function that will reput all the controls for each
> instence, no ? . Thanks in advance


> > Really thanks i'll see if the bug has persisted but i find it is a bit
> > stupid that there's no Hide() or Visible propriety, don't you think ?


> > > Greetings. Uh, I found out from an old thread
> > > (search on "can't close") that Panels and things
> > > that inherit from Panels like TabPages have this
> > > bug that if you remove or clear them you can't
> > > close the form. You have to Dispose the TabPage
> > > before removing. (I'm using the first release
> > > version of VS and haven't updated so this bug
> > > may be fixed in the latest?)

> > > Of course, now, for your original question you
> > > would have to Dispose, then Remove to make
> > > not visible and completely reinstantiate to
> > > re-add the page. or catch close and clean up
> > > with the pages yourself. Kinda yucky.

> > > Sorry I couldn't be of more help...

> > >                          -Yamo-



Tue, 14 Dec 2004 18:30:58 GMT  
 Hide a TabPage
One method I saw and now use is to have another tabcontrol with visible
property set to false on your form. When you want to hide the tabpage just
transfer it to the hidden tab. That way you don't lose it.

Below is some code posted on the windowsforms group that will give you the
basic idea:

Hth,

Morkai

-----
The visible property of tab pages can only make the tab pages invisialbe
without hiding the respective tabs.

One workaround is to create a second tab control, make it invisible, and
move the tabs you don't need currently to it.  Any information they have on
them will be retained but they will be invisible.
In the code sample, I have two tab controls in the form: 1 is visible, 2 is
invisible. and two buttons.

                private void button1_Click(object sender, System.EventArgs e)
                {
                        tabControl2.TabPages.Add(tabPage1);
                        tabControl1.TabPages.Remove(tabPage1);
                }

                private void button2_Click(object sender, System.EventArgs e)
                {
                        tabControl1.TabPages.Add(tabPage1);
                        tabControl2.TabPages.Remove(tabPage1);
                }

Best regards,
yhhuang
VS.NET, Visual C++
Microsoft



Tue, 14 Dec 2004 18:40:42 GMT  
 Hide a TabPage
xcellent, thank yuu !!


Quote:
> One method I saw and now use is to have another tabcontrol with visible
> property set to false on your form. When you want to hide the tabpage just
> transfer it to the hidden tab. That way you don't lose it.

> Below is some code posted on the windowsforms group that will give you the
> basic idea:

> Hth,

> Morkai

> -----
> The visible property of tab pages can only make the tab pages invisialbe
> without hiding the respective tabs.

> One workaround is to create a second tab control, make it invisible, and
> move the tabs you don't need currently to it.  Any information they have
on
> them will be retained but they will be invisible.
> In the code sample, I have two tab controls in the form: 1 is visible, 2
is
> invisible. and two buttons.

> private void button1_Click(object sender, System.EventArgs e)
> {
> tabControl2.TabPages.Add(tabPage1);
> tabControl1.TabPages.Remove(tabPage1);
> }

> private void button2_Click(object sender, System.EventArgs e)
> {
> tabControl1.TabPages.Add(tabPage1);
> tabControl2.TabPages.Remove(tabPage1);
> }

> Best regards,
> yhhuang
> VS.NET, Visual C++
> Microsoft



Tue, 14 Dec 2004 19:38:16 GMT  
 
 [ 9 post ] 

 Relevant Pages 

1. Broken Show() and Hide() for Forms.Form.TabPage

2. Hide TabPage

3. TabPage question

4. How to display richtextbox scrollbars on a tabpage?

5. Newbit: help with TabPage and Controls

6. Adding objects to a tabpage programmitically

7. TabControl tabpage change

8. Catching the TabPage change event?

9. dynamically adding separately created tabpage to tabcontrol

10. is it possible to show Form on TabPage ?

11. TabPage - OnChange

12. Get the TabPage from a MouseClick???

 

 
Powered by phpBB® Forum Software