List of all components

  • Thread starter Thread starter gusse.net
  • Start date Start date
G

gusse.net

how do I get a list of all components on a form using reflection ??

or is there another way of doing this ??

can anyone help ??
 
gusse,

What are all components on a form in your idea, normally those things have
the name controls and can be get easily in a recursive loop?




Cor
 
Hello gusse,
how do I get a list of all components on a form using reflection ??

Assuming you are in the constructor (and I understand all kinds of missing
details about your question correctly <g>):

Type formType = this.GetType( );
FieldInfo[] fields = formType.GetFields(BindingFlags.Instance |
BindingFlags.NonPublic);
foreach (FieldInfo field in fields) {
if (typeof(Component).IsAssignableFrom(field.FieldType))
Debug.WriteLine(field.Name);
}
or is there another way of doing this ??

Is there another way of doing what?


Oliver Sturm
 
Back
Top