components

The designer defines a variable components:

partial class Form1

{

/// <summary>

/// Required designer variable.

/// </summary>

private System.ComponentModel.IContainer components = null;


but it only uses when there are no controls in the form. When i create a control the variable is not used. I want to know if anyone can explain me why is it defined what is it purpose



Answer this question

components

  • Twisted Hardware

    Thank you very much, it really cleared things for me.
  • Manitra

    It is used by the designer to host non-visual controls of your form. Non-visual controls includes Timer, ImageList, NotifyIcon, Menu and others that has no design-time rendering.

    Try dropping a Timer or ImageList to your form, and investigate the generated code, you'll see that the declared components variable will then be passed as parameter for the constructor in instance declaration of these non-visual controls.

    Another thing, since these non-visual controls inherits from component or implements IComponent, they will not be added to the form's (or other container control's) ControlCollection.

    Hope this help,

    -chris

  • components