+ 1

How to dispose the dynamically created panels in vb.net

I was created panels by for loop and then after i want to dispose all the created panels when click delete button.

28th Nov 2018, 2:32 PM
Himanshu Gajjar
Himanshu Gajjar - avatar
2 Answers
+ 1
First you have to store them in a list then simply remove them by clearing the list. I hope that will work
28th Nov 2018, 4:25 PM
Bad_Bits
Bad_Bits - avatar
+ 1
Write this code in the delete button event handler For Each ctl As Control ln Me. Controls If TypeOf ctl Is Panel Then Me. Controls. Remove(ctl) EndIf Next
28th Nov 2018, 6:21 PM
Asgar Ali
Asgar Ali - avatar