Groups | Blog | Home
all groups > dotnet windows forms databinding > april 2005 >

dotnet windows forms databinding : How to use Datagrid with ArrayList


Roy Chastain
4/15/2005 1:09:58 PM
I have an ArrayList that contains multiple instances of one type of object.
These objects have public properties that can be read and written.

How do I get these properties to display in columns in the datagrid?

I have bound the arraylist to the datagrid and I have tried defining a tablestyle and columnstyles just like I would with a
dataset, but that is not working.

When the control displays, it shows the row header for each row and it shows a VERY skinny column header with no text even though
I put header text in at design time. BTW the columns do not show in the grid at design time.

Thanks
-------------------------------------------
Roy Chastain
v-kevy NO[at]SPAM online.microsoft.com
4/16/2005 12:00:00 AM
Hi Roy,

We have reviewed this issue and are currently researching on it. We will
update you ASAP. Thanks for your patience!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
v-jetan NO[at]SPAM online.microsoft.com (
4/17/2005 12:00:00 AM
Hi Roy,

Thanks for your post!!

Based on my understanding, you want to know how to do databinding with
ArrayList and DataGrid control, which always does not work on your side. If
I misunderstand you, please feel free to tell me. Thanks

Actually, to use ArrayList object as the DataSource, we should set
DataGridTableStyle.MappingName property to "ArrayList". Then for each
DataGridColumnStyle, we should set its MappingName property to the inner
item's corresponding public property name. For more information, please
refer to the article below:
"4.7 How can I bind an ArrayList to a DataGrid?"
http://64.78.52.104/FAQ/WinForms/FAQ_c43c.asp#q818q

There is also a sample project in this link. For your information.
========================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
v-jetan NO[at]SPAM online.microsoft.com (
4/20/2005 12:00:00 AM
Hi Roy,

Does my reply make sense to you? If you need further help, please feel free
to tell me, thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Roy Chastain
4/22/2005 8:43:16 AM
Yes, thank you very much. I have even managed to implement IBindingList in a class based on an array list so that I can sort etc.

[quoted text, click to view]

-------------------------------------------
Roy Chastain
v-jetan NO[at]SPAM online.microsoft.com (
4/25/2005 12:00:00 AM
[quoted text, click to view]
array list so that I can sort etc.
Cool!!

If you need further help, please feel free to post. Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
AddThis Social Bookmark Button