Win64ControlsWin32Visual Studio 2008.NET 3.0Visual Studio 2005Visual Studio 2010Design / Graphics.NET4Advanced.NET 2.0.NET 3.5Windows FormsC# 2.0BeginnerC# 3.5C# 3.0C# 4.0IntermediateDevVisual Studio.NETC#
How To Hide Or Show .NET Tabs Programmatically





5.00/5 (5 votes)
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();
}
private List _HiddenPages;
public List 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);
}
}