当用UserControl
C#处理时会发生什么事?我想抓住它做一些清理,但在查看设计师可用的事件列表后,似乎没有这样的事情?
Dav*_*ave 11
创建用户控件时,将在yourUserControlName.Designer.cs文件中自动为您创建Dispose方法.添加该方法的任何清理代码.您可能希望将自动生成的代码更改为以下内容:
protected override void Dispose(bool disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
// your clean up code here
}
base.Dispose(disposing);
}
Run Code Online (Sandbox Code Playgroud)
这样,清理代码将不依赖于组件对象.