473,386 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

workaround: hiding tabpages on a tabcontrol

Although lots of people described how to workaround the lack of ability
to hide and show tab pages on a tab control, I couldnt find a code
example so I made one. Create a class that inherits from the
tabcontrol and then add the following

Private htVisibleVal As New Hashtable
Private htVisibleKey As New Hashtable
Private htInvisibleKey As New Hashtable

'stores the current tabpages
Public Sub Initialise()
Dim tp As TabPage
Dim i As Integer
htVisibleVal.Clear()
htVisibleKey.Clear()
htInvisibleKey.Clear()

For i = 0 To Me.TabPages.Count - 1
htVisibleKey.Add(Me.TabPages(i), i)
htVisibleVal.Add(i, Me.TabPages(i))
Next

End Sub

'removes the tabpage from the tabpages collection and visible
hashtables and adds it to the invisible hashtable
Public Sub HideTabPage(ByVal tpIn As TabPage)

Dim tp As TabPage
Dim i As Integer = htVisibleKey(tpIn)
htVisibleKey.Remove(tpIn)
htVisibleVal.Remove(i)
htInvisibleKey.Add(tpIn, i)
Me.TabPages.Remove(tpIn)
End Sub
'moves the tabpage from the invisible hashtable to the visible one.
Then iterates through the visible hashtable
'adding them back to the tabcontrol
Public Sub ShowTabPage(ByVal tpIn As TabPage)

Dim i As Integer = htInvisibleKey(tpIn)
htInvisibleKey.Remove(tpIn)
htVisibleKey.Add(tpIn, i)
htVisibleVal.Add(i, tpIn)

Me.TabPages.Clear()
For i = 0 To htVisibleVal.Count - 1
Me.TabPages.Add(htVisibleVal(i))
Next
End Sub

call the initialise method after the windows designer has added the tab
pages to its tabpage collection. You only need to do this once.

It could probably use some exception catching but hopefully it will get
you started.

Jan 9 '06 #1
2 1667
Kevin,

This (and more about the tabpage) is completely described at Mike his page
about tab controls.

http://dotnetrix.co.uk/tabcontrols.html

Probably is the newsgroup

microsoft.public.dotnet.languages.vb better for this kind of questions for
you.

Cor
Jan 9 '06 #2
Thanks for your reply Cor, that is a useful site, however it didnt
contain anything about storing the position of a tab page when you
'hide' so that it can be added in the same position afterwards. The
insert tab function is useful though.

Also a slight tweak to my code, the loop in ShowTabPage should be:

For i = 0 To htVisibleVal.Count + htInvisibleKey.Count - 1
If htVisibleVal.Contains(i) Then
Me.TabPages.Add(htVisibleVal(i))
Next

Jan 9 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: StressPuppy | last post by:
(posted this in VB group but then realized I probably should have posted here) I have a TabControl with several TabPages. Upon startup, I only want to show the first TabPage, hiding the rest....
4
by: Peter Row | last post by:
Hi, I have created a UserControl which is subsequently hosted on a standard form. My control has a TabControl on it but it has no TabPages configured. At runtime I create X pages and put a...
3
by: Boris Condarco | last post by:
Hi gurus, I am using tabControl in Windows forms and would like to hide some of the tabPages, does anyone of you can point me about it, i would really appreciate your helping me...! thanx a...
4
by: Amjad | last post by:
How do I hide a tab in a TabControl that contains 3 tabs I tried the following and it didn't work tabTab2.Hide( tabTab2.Visible = Fals Amjad
7
by: Richard | last post by:
I have a form with seven tapages. These span only one record with a large number of fields (textboxes). On Tabpage1 I display a number of read-only text boxes. This displays information about...
1
by: Turxoft | last post by:
I want to use tabcontrol in my form.I add several tab pages but want to hide the tabs.
2
by: Turxoft | last post by:
I have a tabcontrol in my form. I want to hide the tabpages. I want the user cant change the tabpages and do it by code.how can I?
11
by: Pete Kane | last post by:
Hi All, does anyone know how to add TabPages of ones own classes at design time ? ideally when adding a new TabControl it would contain tab pages of my own classes, I know you can achieve this with...
8
by: M K | last post by:
How do you hide individual tabs? I have tried .Hide() but it hides them all? Mark
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.