How do I delete/remove custom control from a form programmatically?
Hello I created a custom control and add it to a form programatically.
The user can add and move them all over the form.
The problem is when I want to clear the form of my user control I don't know how.
I created an array of my control called ctlCorkNotes
Say I create ctlCorkNotes(1) and now I want to delete it.
How do I do this so it is gone and would have to recreate it to show up again?
Thanks for your help.
Mythos
Re: How do I delete/remove custom control from a form programmatically?
First of all, set the visible property to false and then use this method:
ctlCorkNotes.Dispose()
That will release all resources to your control.
Re: How do I delete/remove custom control from a form programmatically?
Quote:
Originally Posted by
Zeelia
First of all, set the visible property to false and then use this method:
ctlCorkNotes.Dispose()
That will release all resources to your control.
The Visible property is irrelevant. Call the control's Dispose method and then Remove it from its Parent's Controls collection.
Re: How do I delete/remove custom control from a form programmatically?
off-topic: I like irrelevance :P
No, but honestly I don't know why I wrote that..