When I create a Form, the auto-generated code doesn’t include an overrided Dispose method. Does that mean Dispose is not being called for all the controls in the form?
When I create a Form, the auto-generated code doesn’t include an overrided Dispose method.
Share
When you call
Disposeon the form, it will callDisposefor each control in itsControlscollection. Those controls will in turn do the same, so in the end all controls’Disposemethod should have been invoked. Note that this is not based on whether the controls are present in the designer or not; it is based on what control instances that are found in theControlscollection of the form at the time the call toDisposeis done.The only case when I could see that this would not happen is if you create some container control yourself and override
Disposewithout propagating the call either to the base class or iterate over the contained controls and callDisposeon them.