Disable and hide a TabPage

Aan picture Aan · Oct 15, 2012 · Viewed 82.4k times · Source

How I can make a TabPage in a TabControl visible/hidden and enabled/disabled?

Answer

Otiel picture Otiel · Oct 15, 2012
  • Enable / disable

    The tabPage.Enabled seems to be working fine, but is marked as "not to be used":

    This API supports the .NET Framework infrastructure and is not intended to be used directly from your code.
    This member is not meaningful for this control.

    So you should disable the tab page by disabling every control in the tab. See this for instance.

  • Show / hide

    There is an existing tabPage.Visible property but it does not seem to have any effect. Besides, it is also marked as "not to be used", and msdn advises to remove the tab page from the tab control in order to hide it:

    // Hide the tab page
    tabControl.TabPages.Remove(tabPage1);
    // Show the tab page (insert it to the correct position)
    tabControl.TabPages.Insert(0, tabPage1);