Iterate through non-ui controls(IContainer components)

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
 
D

DeveloperX

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]
 

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