常に疑わしいソースに移動します。
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 * ... ok、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
と、そこに含まれるコントロールが破棄されます。