Databinding Custom Properties in PropertyGrid

Posts   
 
    
solidstore
User
Posts: 12
Joined: 11-Jul-2005
# Posted on: 10-Feb-2011 12:50:33   

I have an entity class that has a binary field and I want this hidden from the user. I have created a partial class and overriden OnInitClassMembersComplete which deserialize this binary data into a new object. This object is derived from IDictionary. I want to expose each of the name value pairs inside this dictionary so that they appear as properties of the entity class on the propertygrid (which needs to be able to modify them).

If I add these dictionary entries into the custom properties of the entity i was hoping to see them appear in the PropertyGrid control, but they dont.

Is this possible? Essentially i want to data bind the custom properties of the entity class.

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 10-Feb-2011 21:04:12   

Are the members of the dictionary "dynamic" - ie can the number and names of them change...? If not, would it be possible to create actual properties in the partial class which expose them?

If they are dynamic - hmmm... I'll have a think about this.

Matt

solidstore
User
Posts: 12
Joined: 11-Jul-2005
# Posted on: 11-Feb-2011 02:52:39   

Yes they are dynamic. However they will always be string values.

Can I populate the entity custom properties collection? Does this databind?

I'm not seeing it appear.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 11-Feb-2011 05:30:32   

I never used PropertyGrid, but from the info out there, it seems you need another structurer to bind to, wrapping your dictionary in a ICustomTypeDescriptor class. See this: http://www.differentpla.net/content/2005/02/using-propertygrid-with-dictionary

So you could create a custom property on a partial class of your entity, the type must be that you implemented before (see link above). Then I think you would be able to bind the dictionary to the PropertyGrid. Btw, this is not an LLBLGen issue, you just need to figure it out how to pass a Dictionary property of 'any' class to a PropertyGrid.

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39862
Joined: 17-Aug-2003
# Posted on: 11-Feb-2011 10:31:13   

Or use the PropertyBag code in Algorithmia, our open source algorithm and datastructures library which we also use in llblgen pro v3, to build the dynamic property grids for settings and properties simple_smile

Frans Bouma | Lead developer LLBLGen Pro