总是去怀疑的源头:
Form.Dispose
看起来有点像这样:
protected override void Dispose(bool disposing)
{
if (disposing)
{
... lots and lots of weird optimized checks ...
base.Dispose(disposing);
好的......Form
是一个ContainerControl
,所以:
ContainerControl.Dispose
:
protected override void Dispose(bool disposing)
{
if (disposing)
{
this.activeControl = null;
}
base.Dispose(disposing);
this.focusedControl = null;
this.unvalidatedControl = null;
}
Grrr* ...好吧,ContainerControl
是一个Control
:
Control.Dispose
:
protected override void Dispose(bool disposing)
{
... a whole lot of resource reclaiming/funky code ...
ControlCollection controls = (ControlCollection)
this.Properties.GetObject(PropControlsCollection);
if (controls != null)
{
for (int i = 0; i < controls.Count; i++)
{
Control control = controls[i];
control.parent = null;
control.Dispose();
}
this.Properties.SetObject(PropControlsCollection, null);
}
base.Dispose(disposing);
所以是的;调用Dispose
Form 将释放其中包含的控件。