Hi,
I implemented "ICustomTypeDescriptor" for getting properties for my model object. Binding works fine for the first level. But i am finding it difficult to bind the hierarchical data.
Each "Parent Object" has a "Child Object" and both has ICustomTypeDescriptor implementation for properties. While creating properties for the "Parent Object", i created a property (PropertyDescriptor) with PropertyType as "Child Object" type. But still the hierarchical layout is not created.
How to create hierarchical field layout in the grid when the DataModel is dealing with dynamic properties (ICustomTypeDescriptor implementation)?
It would be of a great help, if you can give me some sample code to do this.
Thanks,
Sreeram.
Its working for me. Some how i missed this small detail; I created the new property in "Parent Object" as a collection of parent objects and every thing lit up like a christmas tree :) . The hierarchical binding works fine.
Hi Sreeram,
Have you got any example code you could share to demonstrate how you get the grid to display data items implementing ICustomTypeDescriptor? I'm struggling to get the grid to display the custom properties I'm defining.
Thanks
Peter
Peter,
I'll certainly help you out. You can reach me at, sreeram.akella@gmail.com for quick help.
-Sreeram.
Thanks Sreeram,
Your checklist has been a great help and has pointed me in the right direction. I had done steps 2 and 3 (in quite a clumsy fashion) but not 1. Once I changed the code a bit and implemented the TypeDescriptionProvider I was able to bind to the grid.
I have not yet tried hierarchical data and may well be back to ask for further advice when I get to that stage.
I don't have any code sample right now. I got to make a sample for you, i will do that when ever i find some time.
Meanwhile if you can share your code, i can correct it. Also, i can give you a checklist of items for ICustomTypeDescriptor to work.
1. "TypeDescriptionProvider" should be register using TypeDescriptor.AddProvider(provider, typeof(Model)).
2. The data and property should be gelled in "PropertyDescriptor" class.
3. "ICustomTypeDescriptor" interface should be implemented to return the properties for the model.
4. For hierarchical data to be binded, add the collection object (2nd level object) in the model as a reflect property while returning the properties from "GetProperties" call in ICustomTypeDescriptor implementation.
Hope this helps you.