Julia wrote:
class Document
{
Hashtable Properties ; //Key is the property name
}
class Media
{
Document document;
Status status
string this[string propertyName] //Return property value from the
document
{
}
}
I have a list of media and I would like to bind it to a grid In such a away
that
each property of the document will be displayed in a different column
Implement ICustomTypeDescriptor on Document. It comes down to the fact
that you have to supply a PropertyDescriptorCollection, which for each
property you want to expose a PropertyDescriptor instance. You therefore
have to implement a class derived from PropertyDescriptor.
For each entry in the hashtable 'Properties' you then create a property
descriptor and return it in Document.GetProperties. When you then bind a
collection of Document instances to a grid, each property in the
document will show up as a column.
Be aware though that all document instances in the collection you bind
have to have the same properties.
Frans
--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET:
http://www.llblgen.com
My .NET blog:
http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------