?
Solved

Loop through Indexes in Descending Order

Posted on 2009-05-06
4
Medium Priority
?
812 Views
Last Modified: 2012-05-06
I have 5 tabs (indexed at 0). Users select what options they want and then I remove the rest of the tabs from the end of the tabcontrol.  If they want to add a tab back they can do that also.
My problem is, I need to loop through the tabs in order to remove them.
Lets say a user has selected 4 items, 0 based, so I would need to remove 2 tabs.

As I loop through and remove the tabs, the last index is not longer available so I will get an error.
Is there a way to loop through the tabcount in descending order?

For Each i As Object In Me.lstChkSessions.CheckedItems
 
            s = Me.lstChkSessions.GetItemText(i).ToString
            ft.TabRacing.TabPages(c).Text = s
            Dim view As DataRowView = Me.lstChkSessions.CheckedItems(c)
            ft.TabRacing.TabPages(c).Tag = view.Item("SessionTypeID")
            c = c + 1
 
        Next i
 
        For p As Integer = c To ft.TabRacing.TabCount - 1
            ft.HideTab(ft.TabRacing.TabPages(p).Name)
        Next

Open in new window

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
  • 3
4 Comments
 
LVL 15

Accepted Solution

by:
JackOfPH earned 2000 total points
ID: 24321700
Try this code...
For p As Integer =  ft.TabRacing.TabCount - 1 to c step -1
            ft.HideTab(ft.TabRacing.TabPages(p).Name)
Next

Open in new window

0
 

Author Closing Comment

by:Sheritlw
ID: 31578834
Works great... Thanks
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 24321802
Did it work?
0
 
LVL 15

Expert Comment

by:JackOfPH
ID: 24321803
Glad I could help...
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

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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

718 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