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# |
コードのコピー
|
---|---|
//ファイルをxmlドキュメントとして保存します。 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); } } |
実行時に C1GanttView を XML ファイルに保存するには、以下の手順に従います。
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# |
コードのコピー
|
---|---|
//既存のXMLドキュメントからコンテンツをロードします。 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); } } } |
実行時に C1GanttView を XML ファイルとしてロードするには、以下の手順に従います。