Container collection

  • Thread starter Thread starter Tilfried Weissenberger
  • Start date 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
 
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
 
Back
Top