清洗物件了一种形式,时间和地点? [英] Cleaning objects off a form, Where and When?
问题描述
我有一个简单的Windows窗体应用程序。在窗体上我有有它自己的Dispose方法的自定义类。
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?
是FormClosed事件(即Form1_FormClosed)正确的地方要做到这一点?或者我应该写表单自定义Dispose方法?
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?
有关奖励积分:可以从一个可以重新开放,关闭一次? (显然,如果能够再FormClosed是错误的路要走!)
For bonus points: Can a from be reopend once closed? (Obviously if it can then the FormClosed is the wrong way to go!)
感谢。
推荐答案
时,需要手术一丁点儿。打开解决方案资源管理器窗口旁边的表格的节点。双击窗体的Designer.cs文件。找到Dispose()方法和剪切并粘贴到你的窗体的源代码文件。现在你可以改变它,并呼吁在窗体类一次性对象引用的Dispose方法
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.
这篇关于清洗物件了一种形式,时间和地点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!