TomPhillips
Active member
- Joined
- Feb 24, 2005
- Messages
- 33
- Programming Experience
- 10+
Removing all controls of a type. RESOLVED
I am placing ListBox controls on a form in rows and columns. I then want to remove them and replace them with new ones. When I use code like this:
For Each ctrl As Control In Me.Controls
If TypeOf ctrl Is ListBox Then
ctrl.Dispose()
End If
Next
only every other box gets removed. I can keep running the block over and over till all boxes are gone, but why is this happening and how can I just dispose of all the ListBoxes on a form at once?
I am placing ListBox controls on a form in rows and columns. I then want to remove them and replace them with new ones. When I use code like this:
For Each ctrl As Control In Me.Controls
If TypeOf ctrl Is ListBox Then
ctrl.Dispose()
End If
Next
only every other box gets removed. I can keep running the block over and over till all boxes are gone, but why is this happening and how can I just dispose of all the ListBoxes on a form at once?
Last edited: