One solution would be to encapsulate any disposable Types you are using in classes derived from System.ComponentModel.Component
or which implement System.ComponentModel.IComponent
.
You can then add them to the IContainer that is instantiated by the designer-generated code, and they will be disposed along with other components.
E.g.
class MyDisposableComponent : IComponent
{
... implementation
}
class MyUserControl : UserControl
{
MyDisposableComponent myDisposableComponent;
...
void SomeMethod()
{
myDisposableComponent = new MyDisposableComponent();
components.Add(myDisposableComponent);
// myDisposableComponent will be disposed automatically when the
// IContainer components is disposed by the designer-generated
// Dispose implementation.
}
...
}