want to hide a tabpage in a tabcontrol collection on form load

I would like to have a tabcontrol contain TabPages, some of which will be visible and some of which will be invisible at any time.

I have a TabPage in the Tabcontrol collection which I don't want showing up on form load.

Me.TabControlRight.TabPages.Item("TabPagePreview").Hide() doesn't work.

Thanks for suggestions. -greg

[523 byte] By [hazz] at [2007-12-25]
# 1

Try with

Me.TabPage1.hide()

For Example you create the tabcontrol then you create a tabpage named mytabpage then

use the code Me.mytabpage.hide()

RodFraga at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2

Me.TabControlRight.TabPages.Remove(Me.TabPageTreeView)

hazz at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3

The hide function of tabpages doesn't work. Microsoft is aware of it (i think that i have read that somewhere).

Instead you have to remove it, and if you want to show it again you have to add it..

If you use lets say tabControl1 and tabpage1 the code for "hiding" would be

tabControl1.tabpages.remove(tabpage1)

And then when you "show" it again use:

tabControl1.tabpages.add(tabpage1)

Hope the hide function is working in service pack 1 (the beta has just been released)

DanMikkelsen at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 4

Thanks Dan!

I was having such a problem with TabPages that I ended up just using TabPages for the selectedindex event in order to do the following after adding controls to a collection within a single Panel at runtime.

Select Case TabControlLeft.SelectedIndex

Case 0 'Setup

Me.Panel.Controls.Item("ctl1").Visible = False

Me.Panel.Controls.Item("ctl1").Visible = True

I was really hoping to be able to use TabPages as Containers but I had to change the design. And its always hard to get the Docking and Anchoring right when you have to use more controls than you would like to.

Not sure if any of that made sense. thanks for letting me know about that hide issue ! -greg

hazz at 2007-8-31 > top of Msdn Tech,Visual Basic,Visual Basic General...