By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,677 Members | 1,277 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,677 IT Pros & Developers. It's quick & easy.

Datagrid displaying related ArrayLists

P: n/a
Hi,
I have two classes, Department and Employer, the Department contains an
ArrayList (employers) filled with Employer objects. I want to display an
ArrayList filled with Department objects using a Datagrid. Therefor, I do a
setDatabinding with the Deparments ArrayList and I create two
DatagridTableStyle objects, both with mappingname "ArrayList", and add them
to the Datagrid. However, if I want to add the second DatagridTableStyle, I
get the exception that a table with mappingname "ArrayList" already exists
(makes sense). If I change the Deparment ArrayList to a strongly type array
Department[], and change the mappingname accordingly all works well, of
course. (great feature by the way). I want to know whether it is possible to
display this kind of objectstructure using just ArrayLists.

kind regards,
Christiaan
Nov 15 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hi Christiaan,

Thanks for posting in the group. We are currently researching on this issue
and will update your ASAP.

If there is anything unclear, please feel free to post in the community and
we will follow up.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 15 '05 #2

P: n/a
thnx, I would appreciate that!

"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:L#**************@cpmsftngxa07.phx.gbl...
Hi Christiaan,

Thanks for posting in the group. We are currently researching on this issue and will update your ASAP.

If there is anything unclear, please feel free to post in the community and we will follow up.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 15 '05 #3

P: n/a

Hi Christiaan,

Thank you for posting in the community!

Based on my understanding, you want to specify 2 ArrayLists of
DatagridTableStyle for the same datagrid.

==========================================
If you want to bind your datagrid to arraylist object, all items in the
arraylist must be of the same type as the first item. And when binding to
an ArrayList, you must set the MappingName of the DataGridTableStyle to
"ArrayList" (the type name).

In the document of GridTableStylesCollection class, you will see that:
"CAUTION ...... Consequently, an exception will be thrown if you try to
add new DataGridColumnStyle objects with duplicate MappingName values to
the GridColumnStylesCollection. Alternatively, clear the
GridColumnStylesCollection using the Clear method."
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemwindowsformsgridtablestylescollectioncl asstopic.asp

So DataGrid.TableStyles does not support 2 DatagridTableStyles with the
same MappingName.

I think your workaround of using array is a simple and good.

Another workaround I can think of is creating a new class which inherited
from the ArrayList class, then you can specify different MappingName.

============================================
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.
Have a nice day!!

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.

Nov 15 '05 #4

P: n/a

Hi Christiaan,

Does my reply make sense to you?
If you still have anything unclear, please feel free to tell me, I will
help you.

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.

Nov 15 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.