S
scott
Hi all
First off, thank you for any one that can help.
I have a problem trying to link a DataGrideTableStyle to a DataGrid.
I have a dataset which reads from a file a xml schema and a xml file. This
is done using the ReadXmlSchema and ReadXml.
I then create a DataTable to get access to the tables in the data set.
I then use the DataTable to get one of the tables (there are 2 tables it
holds) and use the DataGride.SetDataBinding to link the datagrid to the
table. It is at this point the error occurs saying
An Unhandled exception of type 'System.ArgumentException' occurred in
System.windows.forms.dll
Additional information: Cannot create a child list for field ShoppintItem.
From what I have been reading I need to use the SetDataBinding because when
I come to use a DataGrideTableStyle that tablestyle needs to be linked using
its MappingName to the dataGrid's DataMember.
I am doing all this so that in the datagride I can hide/Delete some columns
that I don't want to show up.
Below is the code I am using.
Thx for taking the time to read this and help.
Scott.
ds = new DataSet();
ds.ReadXmlSchema(@"C:\Document and Settings. . . . . ");
ds.ReadXml(@"C:\Documents and Settings . . . . ");
System.Data.DataTable dt = new DataTable();
// just checking they are there
string tn = ts.Tables[0].TableName;
string TN = ds.Tables[1].TableName;
System.Data.DataTable DT = ds.Tables[1];
dataGrid1.SetDataBinding(DT, DT.TableName); // <--- Error occurs here.
System.Windows.Forms.DataGridTableStle ts = new DataGrideTableStyle();
ts.MappingName = dataGrid1.DataMember;
DataGrid1.TableStyles.Add(ts);
First off, thank you for any one that can help.
I have a problem trying to link a DataGrideTableStyle to a DataGrid.
I have a dataset which reads from a file a xml schema and a xml file. This
is done using the ReadXmlSchema and ReadXml.
I then create a DataTable to get access to the tables in the data set.
I then use the DataTable to get one of the tables (there are 2 tables it
holds) and use the DataGride.SetDataBinding to link the datagrid to the
table. It is at this point the error occurs saying
An Unhandled exception of type 'System.ArgumentException' occurred in
System.windows.forms.dll
Additional information: Cannot create a child list for field ShoppintItem.
From what I have been reading I need to use the SetDataBinding because when
I come to use a DataGrideTableStyle that tablestyle needs to be linked using
its MappingName to the dataGrid's DataMember.
I am doing all this so that in the datagride I can hide/Delete some columns
that I don't want to show up.
Below is the code I am using.
Thx for taking the time to read this and help.
Scott.
ds = new DataSet();
ds.ReadXmlSchema(@"C:\Document and Settings. . . . . ");
ds.ReadXml(@"C:\Documents and Settings . . . . ");
System.Data.DataTable dt = new DataTable();
// just checking they are there
string tn = ts.Tables[0].TableName;
string TN = ds.Tables[1].TableName;
System.Data.DataTable DT = ds.Tables[1];
dataGrid1.SetDataBinding(DT, DT.TableName); // <--- Error occurs here.
System.Windows.Forms.DataGridTableStle ts = new DataGrideTableStyle();
ts.MappingName = dataGrid1.DataMember;
DataGrid1.TableStyles.Add(ts);