How I can make a TabPage
in a TabControl
visible/hidden and enabled/disabled?
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.
To hide a tab: tabControl. TabPages. Remove(tabPage);
To disable a Tab set its Enabled property to false and similarly to hide a particular Tab set its Visible property to false.
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With