Hiding and Showing Tabpages in a Tabcontrol.

Visiblity property has not been implemented on the TabControl, and there is no Insert method also. Some workaround on this

private void HideTabPage(TabPage tp)
if (tabControl1.TabPages.Contains(tp))

private void ShowTabPage(TabPage tp)
ShowTabPage(tp, tabControl1.TabPages.Count);

private void ShowTabPage(TabPage tp , int index)
if (tabControl1.TabPages.Contains(tp)) return;
InsertTabPage(tp, index);

private void InsertTabPage(TabPage tabpage, int index)
if (index < 0 || index > tabControl1.TabCount)
throw new ArgumentException("Index out of Range.");
if (index < tabControl1.TabCount - 1)
SwapTabPages(tabpage, (tabControl1.TabPages[tabControl1.TabPages.IndexOf(tabpage) - 1]));
while (tabControl1.TabPages.IndexOf(tabpage) != index);
tabControl1.SelectedTab = tabpage;

private void SwapTabPages(TabPage tp1, TabPage tp2)
if (tabControl1.TabPages.Contains(tp1) == false || tabControl1.TabPages.Contains(tp2) == false)
throw new ArgumentException("TabPages must be in the TabControls TabPageCollection.");

int Index1 = tabControl1.TabPages.IndexOf(tp1);
int Index2 = tabControl1.TabPages.IndexOf(tp2);
tabControl1.TabPages[Index1] = tp2;
tabControl1.TabPages[Index2] = tp1;

//Uncomment the following section to overcome bugs in the Compact Framework
//tabControl1.SelectedIndex = tabControl1.SelectedIndex;
//string tp1Text, tp2Text;
//tp1Text = tp1.Text;
//tp2Text = tp2.Text;



Guest Author: Ed Lyons05 Feb 2012

When the tab is readied, are the controls on the form visible? If missing then this is a worthless control!

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: