Ole,
Well, the compiler error is pretty explicit. Did you look in the
designer generated code? My guess is that is where you will find the method
that the designer created.
If you are storing these pens, and want to get rid of them when
disposing, then I would modify that method to dispose of your pens.
If modifying designer-generated code doesn't sound like a great idea to
you, you could create a class which derives from Component, and then add
that to your form. Then, on that component, you would have an Add method
which would take an IDisposable reference, and in that component's dispose
method, you would cycle through and call Dispose on whatever was added
(which you have to keep a list of internally, of course).
--
- Nicholas Paldino [.NET/C# MVP]
-
mv*@spam.guard.caspershouse.com
"Ole" <ol*@blabla.comwrote in message
news:%2****************@TK2MSFTNGP05.phx.gbl...
>I have created an user control (that inherits UserControl) in which I have
defined an override on the Dispose member like this:
protected override void Dispose( bool disposing )
{
try
{
blackPen.Dispose();
redPen.Dispose();
bluePen.Dispose();
}
catch
{ }
}
But the compiler complains with the error message:
"The Control" already defines a member called 'Dispose' with the same
parameter
Any clue what could be wrong?
Thanks
Ole