i have a class that is loaded dynamically and i don't know in advance how many (or of what type) properties it contains. i would like to load all its properties into a PropertyGrid in a way that it would display as it displays a regular class.
for instance, if this is my class:
class TestPropertyObject
{
[Category("Names")]
[Description("Enter your name")]
public string Name { get; set; }
[Category("Numbers")]
[Description("Enter your number")]
public int Number { get; set; }
}
and i use reflection to generate an object and get its properties:
PropertyInfo[] info = obj.GetType().GetProperties()
how do i display the properties in the PropertyGrid?
i already ready many times this article
http://www.codeproject.com/Articles/4448/Customized-display-of-collection-data-in-a-Propert
but i just can't seem to get it to work.
some guidance would be very much appreciated.
thanks!
here is a solution, you just need the instance of the class.
This sample is assuming that you class's property is decorated with Category/description. let me know if I have misunderstood it.
Or by using dynamic object
Make sure you can be able get the namespace of the class.