Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable and hide a TabPage [duplicate]

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

like image 546
Aan Avatar asked Oct 15 '12 11:10

Aan


People also ask

How do I hide my TabPage?

The Hide method of the TabPage will not hide the tab. To hide the tab, you must remove the TabPage control from the TabControl..::. TabPages collection.

How do I hide TabPage from TabControl?

To hide a tab: tabControl. TabPages. Remove(tabPage);

How do I disable tabs in winform?

To disable a Tab set its Enabled property to false and similarly to hide a particular Tab set its Visible property to false.


1 Answers

  • 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);
    
like image 166
Otiel Avatar answered Oct 01 '22 23:10

Otiel