Container collection

  • Thread starter Tilfried Weissenberger
  • Start date
T

Tilfried Weissenberger

Hi,

One thing I found is that Windows.Forms.Form- and
Windows.Forms.UserControl-Objects both create (through VS2k3) a
private System.ComponentModel.Container components = null;
collection
and clean that during the auto-created Dispose() function. But, there
is no code whatsoever which fills this Container with controls!

Is that left to me or do I just disregard this "components" collection
alltogether?

thanks again!

regards, Tilli
 
1

100

Hi Tilfried,
The *components* is used to keep references to all compontens, which are not
controls. Such components are timers, imagelists, etc. They might keep
unmanaged resources that have to be released when the form is disposed. So
those componets have a constructor that accepts IContainer interface.
When you add a timer to a form or user control you can see in the
InitializeComponent method something like

this.timer1 = new System.Windows.Forms.Timer(this.components);

That is the code that fills out the components collection.

HTH
B\rgds
100
 

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