Category / Section
How to save the Schema and the LookAndFeel of WinForms GridGroupingControl and load it back from an XML file?
1 min read
Save and load XML schema
You can save the Schema using WriteXmlSchema() and save the LookAndFeel using WriteXmlLookAndFeel(). You can then load the saved Schema by using ApplyXmlSchema() and LookAndFeel using ApplyXmlLookAndFeel().
C#
private void btnSaveXmlSchema_Click(object sender, EventArgs e) { //Create xml Files to save the Schema and LooknFeel. XmlTextWriter xw = new XmlTextWriter("GridSchema.xml", System.Text.Encoding.UTF8); XmlTextWriter xwApp = new XmlTextWriter("GridLooknFeel.xml", System.Text.Encoding.UTF8); xw.Formatting = System.Xml.Formatting.Indented; //Save the Schame of the GGC. this.gridGroupingControl1.WriteXmlSchema(xw); //Save the LookAndFeel of the GGC. this.gridGroupingControl1.WriteXmlLookAndFeel(xwApp); xw.Close(); xwApp.Close(); Console.WriteLine("Schema is saved"); } private void btnLoadXmlSchema_Click(object sender, EventArgs e) { //Read the XMl Files. XmlReader xr = new XmlTextReader("GridSchema.xml"); XmlReader xrApp = new XmlTextReader("GridLooknFeel.xml"); //Apply the Xml Schema to the GGC. this.gridGroupingControl1.ApplyXmlSchema(xr); //Apply the LookAndFeel to the GGC. this.gridGroupingControl1.ApplyXmlLookAndFeel(xrApp); xr.Close(); xrApp.Close(); Console.WriteLine("Schema is Loaded"); }
VB
Private Sub btnSaveXmlSchema_Click(ByVal sender As Object, ByVal e As EventArgs) 'Create xml Files to save the Schema and LookAndFeel. Dim xw As New XmlTextWriter("GridSchema.xml", System.Text.Encoding.UTF8) Dim xwApp As New XmlTextWriter("GridLooknFeel.xml", System.Text.Encoding.UTF8) xw.Formatting = System.Xml.Formatting.Indented 'Save the Schame of the GGC. Me.gridGroupingControl1.WriteXmlSchema(xw) 'Save the LookAndFeel of the GGC. Me.gridGroupingControl1.WriteXmlLookAndFeel(xwApp) xw.Close() xwApp.Close() Console.WriteLine("Schema is saved") End Sub Private Sub btnLoadXmlSchema_Click(ByVal sender As Object, ByVal e As EventArgs) 'Read the XMl Files. Dim xr As XmlReader = New XmlTextReader("GridSchema.xml") Dim xrApp As XmlReader = New XmlTextReader("GridLooknFeel.xml") 'Apply the Xml Schema to the GGC. Me.gridGroupingControl1.ApplyXmlSchema(xr) 'Apply the LookAndFeel to the GGC. Me.gridGroupingControl1.ApplyXmlLookAndFeel(xrApp) xr.Close() xrApp.Close() Console.WriteLine("Schema is Loaded") End Sub
Samples: