Iterate through non-ui controls(IContainer components)

  • Thread starter Thread starter D2
  • Start date Start date
D

D2

Hi,

I need to find all the non-ui controls like errorproviders that have
been dropped in the form. Unlike form.controls property, I dont see
any collection that maintains all the non-ui controls dropped in the
form.

After scanning various posts on the newsgroups, I came to know that
these are maintained in the following member variable (declared in the
designer file):

private System.ComponentModel.IContainer components = null;

However, in my case this is always null.

I'm just wondering if anyone has an idea about where I can find non-ui
controls at runtime?

Thanks,
D2
 
Hi,

I need to find all the non-ui controls like errorproviders that have
been dropped in the form. Unlike form.controls property, I dont see
any collection that maintains all the non-ui controls dropped in the
form.

After scanning various posts on the newsgroups, I came to know that
these are maintained in the following member variable (declared in the
designer file):

private System.ComponentModel.IContainer components = null;

However, in my case this is always null.

I'm just wondering if anyone has an idea about where I can find non-ui
controls at runtime?

Thanks,
D2

I just dropped a notifyIcon on a form and put this in a button.

foreach(System.ComponentModel.IComponent c in
this.components.Components)
{
Console.WriteLine(c.ToString());
}

The output was:

[System.Windows.Forms.NotifyIcon]
 
Back
Top