?
Solved

Retrieve TabPage from ArrayList

Posted on 2009-05-06
3
Medium Priority
?
402 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 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

764 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