S
Stewart Berman
I have an application that populates a DataGridView control with an XML file:
private void Form1_Load(object sender, EventArgs e)
{
dataGridView1.DataSource = gridDataSet;
gridDataSet.ReadXml("E:\\ImageControl.xml");
dataGridView1.DataMember = "Images";
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView1.ColumnHeadersVisible = true;
dataGridView1.Columns.GetFirstColumn(DataGridViewElementStates.Visible).Visible = false;
dataGridView1.AllowUserToAddRows = false;
dataGridView1.AllowUserToDeleteRows = false;
}
The interface has an Add and a Delete button for adding and deleting entries.
How do I setup the XML file so the grid only shows the headers?
The schema is:
<?xml version="1.0" standalone="yes" ?>
<xs:schema id="DataSet1" targetNamespace="http://www.tempuri.org/DataSet1.xsd"
xmlns:mstns="http://www.tempuri.org/DataSet1.xsd"
xmlns="http://www.tempuri.org/DataSet1.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified"
elementFormDefault="qualified">
<xs:element name="DataSet1" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Images" minOccurs="0" >
<xs:complexType>
<xs:sequence>
<xs:element name="Sequence"
msdata:AutoIncrement="true" type="xs:int" />
<xs:element name="Name" type="xs:string"
minOccurs="0" />
<xs:element name="Location" type="xs:string"
minOccurs="0" />
<xs:element name="Style" type="xs:string"
minOccurs="0" />
<xs:element name="Duration" type="xs:int"
minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
The initial XML file has:
<?xml version="1.0" encoding="utf-8"?>
<DataSet1 xmlns="http://www.tempuri.org/DataSet1.xsd">
<!--SABBackgroundSlideShow Image Conrol-->
<Images>
<Sequence></Sequence>
<Name></Name>
<Location></Location>
<Style></Style>
<Duration></Duration>
</Images>
</DataSet1>
When the application opens the grid shows the headers and a row of empty cells. If I delete the
<Images> section. The system complains that it cannot find the table. If I delete just the children
un Images the system complains that there aren't any child entries defined.
So how do I stop the empty row from displaying?
private void Form1_Load(object sender, EventArgs e)
{
dataGridView1.DataSource = gridDataSet;
gridDataSet.ReadXml("E:\\ImageControl.xml");
dataGridView1.DataMember = "Images";
dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView1.ColumnHeadersVisible = true;
dataGridView1.Columns.GetFirstColumn(DataGridViewElementStates.Visible).Visible = false;
dataGridView1.AllowUserToAddRows = false;
dataGridView1.AllowUserToDeleteRows = false;
}
The interface has an Add and a Delete button for adding and deleting entries.
How do I setup the XML file so the grid only shows the headers?
The schema is:
<?xml version="1.0" standalone="yes" ?>
<xs:schema id="DataSet1" targetNamespace="http://www.tempuri.org/DataSet1.xsd"
xmlns:mstns="http://www.tempuri.org/DataSet1.xsd"
xmlns="http://www.tempuri.org/DataSet1.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified"
elementFormDefault="qualified">
<xs:element name="DataSet1" msdata:IsDataSet="true">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="Images" minOccurs="0" >
<xs:complexType>
<xs:sequence>
<xs:element name="Sequence"
msdata:AutoIncrement="true" type="xs:int" />
<xs:element name="Name" type="xs:string"
minOccurs="0" />
<xs:element name="Location" type="xs:string"
minOccurs="0" />
<xs:element name="Style" type="xs:string"
minOccurs="0" />
<xs:element name="Duration" type="xs:int"
minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
The initial XML file has:
<?xml version="1.0" encoding="utf-8"?>
<DataSet1 xmlns="http://www.tempuri.org/DataSet1.xsd">
<!--SABBackgroundSlideShow Image Conrol-->
<Images>
<Sequence></Sequence>
<Name></Name>
<Location></Location>
<Style></Style>
<Duration></Duration>
</Images>
</DataSet1>
When the application opens the grid shows the headers and a row of empty cells. If I delete the
<Images> section. The system complains that it cannot find the table. If I delete just the children
un Images the system complains that there aren't any child entries defined.
So how do I stop the empty row from displaying?