• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 366
  • Last Modified:

How to properly dispose of a custom control.

I have built a custom control and it works great except for one thing.  When I close the form it is on, the control is not properly disposed of, infact, if I call the form again, some the the displayed data is duplicated (due to the Load event firing again).  The form and placement of the custom control is all done at runtime.  So, I need to deal with the disposing of the control within the control itself.
0
David L. Hansen
Asked:
David L. Hansen
1 Solution
 
jppintoCommented:
YourControl.Dispose()
0
 
Hawkvalley1Commented:
Also if you were opening the form by it's default instance(form2.show - instead of dim f2 as new form2) you will run into this problem.
0
 
DeathraceCommented:
Hi,
You need to override the dispose method, i feel you didn't google it..there's a lot of stuff which explains
how to do this try this an example of overriding dispose method for custom controls.
http://www.akadia.com/services/dotnet_user_controls.html
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now