what is IContainer components for?

G

Guest

When I create a new form a private member
System.ComponentModel.Container components
is created, and appears to be passed to the constructors of various things
like timers.
Can someone explain to me what the purpose of this is. It seems to have
something to do with the Dispose method. If I create (say) a timer manually
in the code and don't pass the components object in the constructor
everything still seems to work OK.
 
S

Stoitcho Goutsev \(100\)

Dave,

some of the components hold on unmanaged resources that needs to be released
upon destroing the component. Forms and UserControls use the container
collection to keep track of such components so they get disposed along with
the form or user control.

Beside this IContainer component collection are used in design time by the
desingener host to keep track of all objects on the design surface. However
it has nothing to do with the Container object that you see in the Form
class.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top