Getting list of controls from a form

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to get the list of all of the controls on a form which works great
except for getting the name of the HelpProvider. For instance:
for (int i = 0; i < this.Controls.Count; i++)
{
temp = this.Controls.Name;
}
will give me all of the textboxes, treeviews, etc on a form, but will not
give me the name of the helpprovier. Any suggestions of how to do this?

Thanks!
 
Hi Susan,

HelpProvider is not a windows control.
It is a component, that is placed in the "Component Tray".

I'm not sure that.
But AFAIK it can be impossible to get list of
components that does not add into its container
(which inherith IContainer interface).

Look into "InitializeComponent()" method to assure that
the HelpProvider is not added to any container.

Regards

Marcin
 
Hi,

Unfortunally there is no way of doing that, at least in that way, as
HelpProvider is a Component it does not is included in the Controls
collection, nor in any collection like Components where all the components
are listed

There is a components collection but it does not include ALL the components
that you include, I'm not very clear of why some are include and some not,
HelpProvider is not btw.

with that in mind then you have only one way to do what you want,
Reflection, this only works IF the class has a member of that type ( it will
works if you use the designer to include the HelpProvider)

of course, you could always create a property that return it, or null if the
form does not support it.


cheers,
 
Back
Top