Tuesday, May 29, 2007

Hiding Tabs ain't the same anymore

If you are like me and remember VB6 all too well this code would appear to be the logical way to hide a tab:

TabControl1.TabPages(1).Visible = False

Now althought this compiles it does nothing

What's stranger is that:
TabControl1.TabPages(1).Enabled = False
does work as expected!!

So the only way is to remove it. But don't worry it does not unload it from memory so we can always add it back into the tabpages collection to get it back:

TabControl1.TabPages.Remove (TabPage1) or RemoveAt(index)
and
TabControl1.TabPages.Add(TabPage1)
to get it back. What's more make sure you use the object as the parameter and not a string :)

No comments: