I have a simple Windows form application. On the form I have a custom class that has it's own Dispose method.
So the question is when should I call this?
Is the FormClosed event (i.e. Form1_FormClosed) the correct place to do this? Or should I be writing a custom Dispose method for the form?
For bonus points: Can a from be reopend once closed? (Obviously if it can then the FormClosed is the wrong way to go!)
Thanks.
A wee bit of surgery is required. Open the node next to your form in the Solution Explorer window. Double-click the Designer.cs file for the form. Locate the Dispose() method and cut-and-paste it into your form's source code file. Now you can alter it and call the Dispose methods on the disposable object references in your form class.
Pre-empting: no, it is okay to edit this part of the designer file. Only the section in the #region is off limits.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With