Solved

Retrieve TabPage from ArrayList

Posted on 2009-05-06
3
353 Views
Last Modified: 2012-05-06
I have been looking on the net for a way to hide/show tabpages in a tabcontrol.
I found a topic on adding the tabpages to an arraylist so they can be easily retrieved after being removed.
I have them hiding/removing using

Private aHideTabPages As New ArrayList()
    Public Sub HideTab(ByVal t As Object)
        aHideTabPages.Add(Me.TabRacing.TabPages(t))
        'Remove page from tabcontrol
        TabRacing.TabPages.RemoveAt(t)
    End Sub

But how do I bring back the correct tab?
I looked all over the net trying to find a solution, with no luck, so I tried ---
Private Sub ShowTab(ByVal t As Object)
        TabRacing.TabPages.Add(aHideTabPages.Item(t))
End Sub
This doesn't work.
Please provide an example (no links please) of how I would retrieve the correct tabpage back from the arraylist.
Thanks
0
Comment
Question by:Sheritlw
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
oobayly earned 500 total points
ID: 24319906
First of all, use a Generics as they're type safe.

The question is, how do you know which tab you want to retrieve, are you doing it by name? By index is tricky as the index will change as tabs are removed and added.

Do you need the tabs to be replaced in the tab control in a specific order, or can the be appended to the end of the the tab control?

You're using t as an object in both methods you've given us, can we assume that it's an integer? It would be a good idea specify Option Strict On in your project too.

The following code uses a string (Tab Name) as a key to keep track of the tabs in both the TabControl & the dictionary of removed tabs.
Dim tabs As New System.Collection.Generic.Dictionary(Of String, TabPage)
 

Private Sub RemoveTab(name As String)

  Dim tab As TabPage = TabRacing.TabPages(name)
 

  tabs.Add(name, tab)

  TabRacing.TabPages.Remove(tab)

End Sub
 

Private Sub RetrieveTab(name As String)

  Dim tab As TabPage = tabs(name)

  tabs.Remove(tab)

  TabRacing.TabPages.Add(tab)

End Sub

Open in new window

0
 

Author Comment

by:Sheritlw
ID: 24321579
The tabpages can just be appended to the end of the tabcontrol.

I am setting up your code now.
Thanks
0
 

Author Closing Comment

by:Sheritlw
ID: 31578581
Great idea.   Thank you .. works great!
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now