Hide Method for TabPage object

G

Guest

I've researched as much as I can on the issue, but I've not found any clearly
defined statement that acknowledges that the Hide method for a TabPage object
just doesn't do what it's supposed to do. This appears to be a bug, or maybe
I'm using it incorrectly?

TabPage.Hide should hide the referenced TabPage object, should it not? Do I
have to 'refresh' the Windows form somehow?

The closest I've come to any means of hiding a TabPage from the TabControl
is to have a secondary TabControl that is hidden, and change the TabPage
object's Parent property to be the hidden TabControl. Then to make it
'reappear' in the original TabControl by reassigning the Parent property. The
only problem being here is that when the TabPage is reassigned to the
original, I have to write code to ensure that it 'reappears' in its
appropriate Index location. This just seems too silly to do, for a method
that is supposed to do this in the first place!
 
M

Mick Doherty

Hide should have been removed from the options.
When a TabPage is not selected it is hidden (not visible).
What you want to do is remove and replace the TabPage. You don't need a
second TabControl to store it as the TabPage is not disposed when you remove
it from the TabControls TabPage Collection.

You will find Hide/Show/Insert/Swap TabPage methods on my site, along with a
few other tips.
http://dotnetrix.co.uk/tabcontrols.html
 
G

Guest

Hi Mike,

Thanks for the reply. Nice site by the way!

However, under the section "Hide and Show Tabpages in a Tabcontrol" from the
link you gave me, I can understand how to use the HideTabPage routine since I
can reference the TabPage on my TabControl by its Index to use as an argument
for the routine, however, I am unsure what to pass as an argument to the
ShowTabPage routine as my TabControl no longer has the 'hidden' TabPage to
reference by either its Index number or its Name?

I'm sorry if this might seem trivial to you, but as I've been programming in
VB6 for quite some time, I'm relatively new to VB.NET.

Thanks.
 
G

Guest

Ahh, I found the answer to my own question. I was unaware until now that I
can reference a TabPage object from the Form object itself.
 
M

Mick Doherty

You Instantiate the TabPage on the Form and then add it to the TabControls
TabPageCollection.

\\\
Sub InitializeComponent()
...
Me.TabPage1 = New System.Windows.Forms.TabPage
...
Me.TabControl1.TabPages.Add(Me.TabPage1)
...
End Sub
///

So the TabPage is actually a Child of the Form.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top