views:

383

answers:

2

When a particular tab on a TabControl is selected, I currently disable all other tabs using TabControl.Enabled = false. I would also like to hide them to avoid confusing users.

Is there any way of doing this without removing the tabs and then adding them back in?

+4  A: 

You can try the .Hide() method or .Visible = false, however I haven't tested it yet.

After a bit of googling, it appears individual tab's cannot be hidden. They must be removed and re-added.

http://social.msdn.microsoft.com/forums/en-US/winforms/thread/aae9149c-4677-46df-b4a2-2f7ec34290a7

www.syncfusion.com/FAQ/windowsforms/faq_c93c.aspx#q957q

Andrew Whittington
+1  A: 

You can easily hide tab by removing them from the TabPages collection of the TabControl. This doesn't destroy the TabPage that you've build in the IDE, so you can show them again just by re-adding them to the TabPages collection.

Hide a tab:

Me.tabControl.TabPages.Remove(Me.tabpageMyNiceTab)

Show this same tab again:

Me.tabControl.TabPages.Add(Me.tabpageMyNiceTab)
GlutenBoy
Thanks, that's what I ended up doing according to Andrew's suggestion.
kasey