Solved

Loop through Indexes in Descending Order

Posted on 2009-05-06
4
808 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
  • 3
4 Comments
 
LVL 15

Accepted Solution

by:
JackOfPH earned 500 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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

809 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