This topic discusses how you can save the content of the C1GanttView project as an XML file and how to load an existing C1GanttView project from an xml file.
GanttView allows you to save the grid in XML format. You can use SaveXml method of the C1GanttView class which serializes the grid content into Xml document. This method serializes the content stored in the cells along with its properties and styles. Other than that, you can also save your file as Xml document at run time.
To save the content of C1GanttView as xml file programmatically, add the below code.
C# |
Copy Code
|
---|---|
//Save file as xml document using (SaveFileDialog dlg = new SaveFileDialog()) { dlg.DefaultExt = ".xml"; dlg.FileName = "gantt"; dlg.Filter = "XML files|*.xml|All files|*.*"; dlg.Title = "Save Gantt View As Xml File"; if (dlg.ShowDialog() == DialogResult.OK) { c1GanttView1.SaveXml(dlg.FileName); } } |
To save the content of C1GanttView as xml file at run time, follow the steps below:
You can de-serialize the grid content from an existing XML file by using the LoadXml method of the C1GanttView class which takes the path of the XML document as a parameter.
Use the code below to load contents for the GanttView control from an existing XML document.
C# |
Copy Code
|
---|---|
//Load the content from an existing XML document using (OpenFileDialog dlg = new OpenFileDialog()) { dlg.DefaultExt = ".xml"; dlg.Filter = "XML files|*.xml|All files|*.*"; dlg.Title = "Load Gantt View From Xml File"; if (dlg.ShowDialog() == DialogResult.OK) { try { c1GanttView1.LoadXml(dlg.FileName); } catch { MessageBox.Show("Bad C1GanttView XML.", dlg.Title); } } } |
To load the content of C1GanttView from an XML file at run time, follow the steps below: