HELP .. TabControl

  • Thread starter Thread starter João Santa Bárbara
  • Start date Start date
J

João Santa Bárbara

Hi all
i have in my application a tab control, with several tabpages, i want to
hide a tabpage how cai i do this ???
i already try to use
Me.tabControl1.TabPages(2).Hide() but the tab continues visible is that a
Bug ??


thsk
JSB
 
To hide the tab page you need to remove it from the collection of pages in
tab control.

Fitim Skenderi
 
Dear João,

I see the same effect, even with

Me.TabControl1.TabPages(2).Visible = false

I don't know exactly why this is. There is, however, a fairly simple
workaround: Reference page to be hidden in a separated TabPage reference and
remove it from the collection. When you needed again, add it from the
reference:


Dim HiddenPage As TabPage
HiddenPage = Me.TabControl1.TabPages(2)

' Remove Page.
Me.TabControl1.TabPages.Remove(HiddenPage)

' Add Page.
Me.TabControl1.TabPages.Add(HiddenPage)


Best regards,

John
 
Please forgive me for butting in, but I have a very similar situation, so
I've been watching this thread.

If I have named the individual TabPages, can I just remove and re-add them
by their individual tabpage names?
 
Dear Bryan,

if I understand you correctly, all you need is the TabIndex member of the
TabPages. The following code assumes that you want to modify a page with the
(object-)name "TabPage2":

' Access by Index (solution for João):
HiddenPage = Me.TabControl1.TabPages(2)

' Access by object (TabPage) name (solution for Bryan):
HiddenPage = Me.TabControl1.TabPages(TabPage2.TabIndex)

' Remove Page - remains unchanged.
Me.TabControl1.TabPages.Remove(HiddenPage)

' Add Page - remains unchanged.
Me.TabControl1.TabPages.Add(HiddenPage)

Dim HiddenPage As TabPage
Me.TabControl1.TabPages.Remove(HiddenPage)
Me.TabControl1.TabPages.Add(HiddenPage)

Best regards,

John
 
Me.tabControl1.TabPages(2).Visible = false

That's what I thought, too. But João is right: Neither .hide nor .visible
work on tab pages, although I don't really understand why (tested in .net
2003, vb). Nevertheless, Remove/Add seems to be a proper work-around.

Best regards,

John
 
Back
Top