473,320 Members | 1,853 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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

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

Nov 17 '05 #1
2 1661
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.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"raymi" <do*************@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
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

Nov 17 '05 #2
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

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Alex Ting | last post by:
Hi Everybody, I have an issue about deleting an object from an arrayList. I've bounded a datagrid using this code where it will first run through all of the code in loadQuestions() and bind a...
0
by: berg | last post by:
All, I am binding an ArrayList full of custom objects to an DataGrid. The property in the custom class are all public. I define a DataGridTableStyle and set the MappingName to "ArrayList". I...
5
by: dlobalzo | last post by:
Hi guys, I've been reading several topics that talk about creating a custom collection to use it as DataSource of a Datagrid. But the fact is I have a class called Action and another class called...
6
by: Steve Amey | last post by:
Hi all I want to be able to throw a custom error up the call stack. I have looked around and it seems as though it's possible, but I can't get it to work :o( Below is some sample code. ...
8
by: Jeffrey Spoon | last post by:
Hello, according to the docs you can update a DataGrid with an ArrayList. I have created an ArrayList and I add these objects: Dim patient1 As New Person patient1.Reading = 1...
18
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the...
2
by: AMDRIT | last post by:
Hello everyone, I have created a custom component and one of its properties is a class object with it's own properties. During runtime, I can assign values to the class object properties just...
4
by: eugenet | last post by:
Hello, I am writing a Windows Forms application using .NET Framework 2.0 and Visual Studio 2005. I would like to use Properties.Settings class to persist a collection of custom objects. For...
0
by: Jeremy Chapman | last post by:
I have included below virtually all the code to a control I'm trying to build. My issue is that an array list property in my control does not get persisted properly to the aspx page code in design...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.