C1.Win.C1FlexGrid Namespace > C1FlexGridBase Class > WriteXml Method : WriteXml(String) Method |
'Usage
Dim instance As C1FlexGridBase Dim fileName As String instance.WriteXml(fileName)
The grid serializes all its contents into the Xml document, including the data stored in the cells, row and column properties, styles, images, etc.
Objects of custom types stored in the grid are also serialized as long as they have an associated System.ComponentModel.TypeConverter that provides conversions to and from string.
The WriteXml(String) method has several overloads that allow you to save several grids into a single Xml document, along with other information stored in the Xml document.
// save a grid into am Xml file
flex.WriteXml(fileName);
// prepare XmlTextWriter XmlTextWriter w = new XmlTextWriter(fileName, new UTF8Encoding(false)); w.Formatting = Formatting.Indented; w.WriteStartDocument(); w.WriteStartElement("Grids"); // save first grid w.WriteStartElement(c1FlexGrid1.Name); c1FlexGrid1.WriteXml(w); w.WriteEndElement(); // save second grid w.WriteStartElement(c1FlexGrid2.Name); c1FlexGrid2.WriteXml(w); w.WriteEndElement(); // close document w.WriteEndElement(); w.Close(); // load document from file XmlDocument doc = new XmlDocument(); doc.Load(fileName); XmlNode n = doc.SelectSingleNode("Grids"); // load grids in reverse order c1FlexGrid2.ReadXml(n.ChildNodes[0]); c1FlexGrid1.ReadXml(n.ChildNodes[1]);
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2