Click here to Skip to main content
Click here to Skip to main content
Alternative Tip/Trick

How To Hide Or Show .NET Tabs Programmatically

, 20 Nov 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
That's far too obscure.All you need to do is store a reference to the TabPage instance which was removed from the TabPages collection of the TabControl. You may use the form where the TabControl is placed for that purpose.You could also create your own TabControl which has an extra property...
That's far too obscure.
All you need to do is store a reference to the TabPage instance which was removed from the TabPages collection of the TabControl. You may use the form where the TabControl is placed for that purpose.
You could also create your own TabControl which has an extra property for "hidden" TabPages and functions for showing/hiding pages, e.g. something like:
public class MyTabControl:TabControl
{
    public MyTabControl():base() 
    {
        _HiddenPages = new List<tabpage>();
    }
 
    private List<tabpage> _HiddenPages;
    public List<tabpage> HiddenPages
    { /*implement get and set here*/ }
 
    public void HidePage(string name)
    {
        TabPage aPage = findShownPageByName(name); //implement that function somewhere
        this.TabPages.Remove(aPage);
        _HiddenPages.Add(aPage);
    }
 
    public void ShowPage(string name)
    {
        TabPage aPage = findHiddenPageByName(name); //implement that function somewhere
        this.TabPages.Add(aPage);
        _HiddenPages.Remove(aPage);
    }
}</tabpage></tabpage></tabpage>

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Bernhard Hiller
Software Developer (Senior)
Germany Germany
No Biography provided

Comments and Discussions

 
GeneralOf course the real question is why the hell didn't MS recogn... PinmemberJames H21-Nov-11 6:59 
GeneralReason for my vote of 5 I was thinking the same thing Bernha... Pinmemberjoshd0616-Nov-11 3:51 
GeneralReason for my vote of 5 thats the way to go Pinmemberjohannesnestler15-Nov-11 12:08 
General+5 Pretty much the approach I use when working with tabs PinmemberReiss15-Nov-11 2:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150128.1 | Last Updated 20 Nov 2011
Article Copyright 2011 by Bernhard Hiller
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid