ArrayList and datagrid

S

Steph

Hello,

I have a problem to bind my arrayList to a datagrid. I have read the article
on MSDN but I dont ' understand where is the bug.

I have 2 classes : DataTableUser and DataFieldUser. One field's type of
DataTableUser is an ArrayList of DataFieldUser; others type are string.

I have one ArrayList with some DataTableUser in.

I bind this arrayList to a datagrid, no problem. So I want now rename Header
Text and try this following code :

....

DataGridTextBoxColumn cs;
DataGridTableStyle ts = new DataGridTableStyle();
ts.MappingName = typeof(ArrayList).Name;


cs = new DataGridTextBoxColumn();
cs.MappingName = "nameDataTableUser";
cs.HeaderText = "name";
cs.Width = 150;
ts.GridColumnStyles.Add(cs);

cs = new DataGridTextBoxColumn();
cs.MappingName = "typeDataTableUser";
cs.HeaderText = "type";
cs.Width = 150;
ts.GridColumnStyles.Add(cs);

cs = new DataGridTextBoxColumn();
cs.MappingName = "infoDataTableUser";
cs.HeaderText = "Info";
cs.Width = 150;
ts.GridColumnStyles.Add(cs);

// Add the custom tablestyle to the DataGrid
dataGrid1.TableStyles.Clear();
dataGrid1.TableStyles.Add(ts);

....

At this time, it's ok, but :
"type" has a + on the datagrid (because it is an ArrayList) and when I click
on it I have a "System.IvalidOperationException".

What can I do ?

Thanks for your help
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top