Good morning, how can I create a property grid leaning on a vector of elements ?
Let me explain: I have a class ( MyPropertyItem ) that in my software that identifies a property. This class has 4 different properties :Name, Description , Category and Value
Other classes inherit from this class and through polymorphism override the Value property going to define the true type of the property (string , integer, datetime , …)
Using LayoutControl was simple to make sure that this allows me to change the various properties . (see attached screenshoot top )
I'd like to take advantage of PropertyGridControl to enhance the property's name , description, category but do not understand how you can do I can .
The documentation says to value the property " SelectedObject " , but my case is different . I have a list of properties List <MyPropertyItem> . If you check the list to the property " SelectedObject " rightly component automatically displays the list and detail of the view that in the "Value" property inserts the appropriate component to change. (see attached screenshoot bottom )
In summary :I have a list of items:list <MyPropertyClass>
the class contains properties that I use in propertygridcontrolName, Description , Category , Value
associating this list I get this:[ 0 ]- Name = [ Value of property]- Description = [ Value of Property]- Category = [ Value of Property]- Value = [ Value of Property][1 ]- Name = [ Value of property]- Description = [ Value of Property]- Category = [ Value of Property]- Value = [ Value of Property]… I would like to get :[ MypropertyClass [0].Name = [ Value of property MyProperty [0]. Value][ MypropertyClass . [1] Name = [ Value of property MyProperty . [1] Value]…
How can I do?
thanks
How do I show in a PropertyGrid properties from a list that contains a list of objects that identify the property itself?
Answers approved by DevExpress Support
Hi,
I recommend that you create a class implementing the ICustomTypeDescriptor interface and use items in your collection as property descriptors. Please take a look at the following ticket that contains an example of an ICustomTypeDescriptor object working with the PropertyGridControl: Q501861: PropertyGridControl and ExpandoObject.
Thanks
You can expose them via the Category and Description property attributes. Override the Attributes property in your property descriptors to return the Category and Description attributes with required values. The PropertyDescriptor Class MSDN article demonstrates how to override the Attributes property.
Let me know if you need additional assistance.