Hi Christi,
check out the CategoryView example. You can modify its SaveSchema and LoadSchema methods to also save and load the dataset.
private void btnSaveXmlSchema_Click(object sender, System.EventArgs e)
{
FileDialog dlg = new SaveFileDialog();
dlg.AddExtension = true;
dlg.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*" ;
if (dlg.ShowDialog() == DialogResult.OK)
{
XmlTextWriter xw = new XmlTextWriter(dlg.FileName, System.Text.Encoding.UTF8);
this.gridGroupingControl1.WriteXmlSchema(xw);
xw.Close();
this.dataSet11.WriteXml("NWCategories.xml", XmlWriteMode.WriteSchema);
}
}
private void btnLoadXmlSchema_Click(object sender, System.EventArgs e)
{
FileDialog dlg = new OpenFileDialog();
dlg.Filter = "xml files (*.xml)|*.xml|All files (*.*)|*.*" ;
if (dlg.ShowDialog() == DialogResult.OK)
{
XmlReader xr = new XmlTextReader(dlg.FileName);
ApplySchema(xr, Path.GetFileName(dlg.FileName), "Engine Schema (" + Path.GetFileName(dlg.FileName) + ")");
xr.Close();
this.dataSet11 = new DataSet1();
ReadXml(this.dataSet11, "NWCategories.xml");
this.gridGroupingControl1.DataSource = this.dataSet11.Categories;
this.gridGroupingControl1.DataMember = null;
}
}
void ApplySchema(XmlReader xr, string info, string undoDescription)
{
GridEngine engine = GridEngine.CreateFromXml(xr);
if (engine != null)
this.gridGroupingControl1.Engine.InitializeFrom(engine);
}
I attached a modified form1.cs file.
Form1_4970.zip
Stefan