Delete controls in a FlowLayoutPanel
Posted on 2006-04-20
I want to delete every Control in a FlowLayoutPanel which have "GT" in their names. I do it like this:
For Each Control As Control In Me.FlowLayoutPanel1.Controls
If InStr(Control.Name, "GT") Then
Control = Nothing
This works great, but because of a reason I can't figure out only half of the controls gets deleted. Which means I will need to run this code 4 times to delete 8 Controls.
8 -> 4 -> 2 -> 1 -> 0
Does anyone know how I can do this the right way?