Solved

Retrieve TabPage from ArrayList

Posted on 2009-05-06
3
396 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

707 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