iterate through properties [modified]
-
Hey all, I was looking for a way to iterate through all properties for a given control, but am only finding ways to access individual properties. I am generating lists of all controls on a target form, but would also like to list all properties for each. Regards. -- modified at 18:48 Sunday 2nd September, 2007
-
Hey all, I was looking for a way to iterate through all properties for a given control, but am only finding ways to access individual properties. I am generating lists of all controls on a target form, but would also like to list all properties for each. Regards. -- modified at 18:48 Sunday 2nd September, 2007
ushering wrote:
I am generating lists of all controls on a target form, but would also like to list all properties for each.
Use reflection. See the documentation for the
System.Reflection
namespace Off the top of my head something like this will get you all the properties on a class (not just controls, any class)Type controlType = myControl.GetType();
PropertyInfo[] properties = controlType.GetProperties();DISCLAIMER: This is as I remember it, I haven't checked that the real methods are exactly as stated.
Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ... My website