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

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
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 
R

raymi

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top