ArrayList of custom class with dynamic properties not displayed correctly in DataGrid

  • Thread starter Thread starter raymi
  • Start date Start date
R

raymi

Hi,

I have a custom class that gets its properties dynamically from a
database at runtime. Therefore I implemented the ICustomTypeDescriptor
in this class and created a a custom PropertyDescriptor. The custom
class also inherits from Component and therefore can be dragged on the
form in the designer view.

So far so good, I can bind properties from my class to textboxes etc.
But when I try to bind an ArrayList containig instances of my custom
class to a DataGrid, for all rows the properties of the first object
are displayed. However, the number of rows is correct.

It seems to me as if the PropertyDescriptor of the wrong instance is
called. The value of the component passed with the GetValue method is
different from the one I pass to the constructor.

Can anybody help?

- raymi
 
Raymi,

Have you tried implementing a collection class which implements the
ITypedList interface? I believe this is needed when you are presenting
dynamic type information in the items that you are exposing.

Hope this helps.
 
Hi Nicholas,

Thanks for your hint, it solved a problem I wasn't even aware of when I
first asked my question. I successfully managed to solve the problem by
changing the GetValue and SetValue method of my PropertyDescriptor. The
problem I had was, that I didn't take the object passed to these
methods into account. But the implementation of the ITypedList
interface was also absolutely necessary.

Thanks for the quick respond.

- raymi
 
Back
Top