I have created a form with 2 controls, a panel and a picturebox. In the panel I create picturebox controls to show thumbnails. These can be dragged and dropped on the larger picturebox below, which creates another picturebox control in a second array (where high quality images will be loaded)
I want to be able to remove controls and I am trying this code which I though should remove them all, I want to do it by index in-case I want to remove just one. I have put the number of the control in the .Tag property:
PanelImagesLoaded is the thumbnail container, can anyone point me to were I am going wrong because this does not unload or remove anything.
Help is greatly appreciated
![Name: dynamic_controls.jpg
Views: 69
Size: 31.0 KB]()
I want to be able to remove controls and I am trying this code which I though should remove them all, I want to do it by index in-case I want to remove just one. I have put the number of the control in the .Tag property:
Code:
Dim c As Integer = 0
For Each pic As PictureBox In PanelImagesLoaded.Controls.OfType(Of PictureBox)()
For Each childc In pic.Controls
If TypeOf childc Is PictureBox Then
c = c + 1
childc.Controls.Remove()
PicBoxArray(c) = Nothing
PicBoxLayoutArray(c) = Nothing
End If
Next
Next
PanelImagesLoaded.Invalidate()
Help is greatly appreciated