S
Scott
Hi all.
A few days ago i ask this question and got a good quick response. I tried
out what they said and it worked. However I have now come to try the same
thing in another program and it does not seem to be working.
I have a dataset that gets its info from an xmlfile and an xml schema. I
then use a DataTable to link to the dataset. I then create a DataGrid and
link it to the Datatable.
So far everything works. Its when i come to create a DataGridTableStyle it
all starts to go wrong. i give the Tablestyle the mapping name of the
Datatable's TableName. Then i add it to the datagrid using the
dataGrid.TableStyles.Add() method. Now when i come to use the tablestyle in
the datagrid to remove a column i get an error saying that there is no
columns.
The code below is what i am trying to do. Can any one see anything wrong
with it ?
Many thanks for taking a look at this.
Scott.
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXmlSchema(@"C:\Doc....ShoppingListDataSet.xsd");
ds.ReadXml(@"C:\Doc....ShoppingList.xml",System.Data.XmlReadMode.Auto);
System.Data.DataTable groupsDT = ds.Tables[0];
System.Data.DataTable itemsDT = ds.Tables[1];
System.Windows.Forms.DataGridTableStyle ts = new DataGridTableStyle();
//dataGrid1.DataMember = "shopping";
ts.MappingName = itemsDT.TableName;
System.Windows.Forms.DataGrid dataGrid = new DataGrid();
dataGrid.DataSource = itemsDT;
dataGrid.TableStyles.Add(ts);
dataGrid.TableStyles[0].GridColumnStyles.RemoveAt(0); // <--- Index is
out of range. Must be non-negative and less than the sieze of the
collectoin.
if i atempt to view the data drig with out the DataGridTableStyle added to
the datagrid all works fine.
A few days ago i ask this question and got a good quick response. I tried
out what they said and it worked. However I have now come to try the same
thing in another program and it does not seem to be working.
I have a dataset that gets its info from an xmlfile and an xml schema. I
then use a DataTable to link to the dataset. I then create a DataGrid and
link it to the Datatable.
So far everything works. Its when i come to create a DataGridTableStyle it
all starts to go wrong. i give the Tablestyle the mapping name of the
Datatable's TableName. Then i add it to the datagrid using the
dataGrid.TableStyles.Add() method. Now when i come to use the tablestyle in
the datagrid to remove a column i get an error saying that there is no
columns.
The code below is what i am trying to do. Can any one see anything wrong
with it ?
Many thanks for taking a look at this.
Scott.
System.Data.DataSet ds = new System.Data.DataSet();
ds.ReadXmlSchema(@"C:\Doc....ShoppingListDataSet.xsd");
ds.ReadXml(@"C:\Doc....ShoppingList.xml",System.Data.XmlReadMode.Auto);
System.Data.DataTable groupsDT = ds.Tables[0];
System.Data.DataTable itemsDT = ds.Tables[1];
System.Windows.Forms.DataGridTableStyle ts = new DataGridTableStyle();
//dataGrid1.DataMember = "shopping";
ts.MappingName = itemsDT.TableName;
System.Windows.Forms.DataGrid dataGrid = new DataGrid();
dataGrid.DataSource = itemsDT;
dataGrid.TableStyles.Add(ts);
dataGrid.TableStyles[0].GridColumnStyles.RemoveAt(0); // <--- Index is
out of range. Must be non-negative and less than the sieze of the
collectoin.
if i atempt to view the data drig with out the DataGridTableStyle added to
the datagrid all works fine.