ComponentOne GanttView for WinForms
In This Topic
    Saving GanttView as an XML File
    In This Topic

    This task shows how to save the C1GanttView as an XML File at run time and in code.

    Save C1GanttView as an XML file at run time

    To save the C1GanttView as an XML file at run time, complete the following:

    1. Click the Save as XML File button from the C1GanttView toolbar button.
      &
      The Save As Xml File dialog box appears.
    2. Browse to the location you wish to save the .xml file.
    3. Click Save in the Save As Xml File dialog box.

    Save C1GanttView from XML file in code

    To save the C1GanttView as an XML file in code, complete the following:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Private Sub btnSaveXml_Click(sender As Object, e As EventArgs)
           Using dlg As 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 Then
                         ganttView.SaveXml(dlg.FileName)
                  End If
           End Using
    End Sub
    

    To write code in C#

    C#
    Copy Code
    private void btnSaveXml_Click(object sender, EventArgs e)
    {
        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)
            {
                ganttView.SaveXml(dlg.FileName);
            }
        }
    }
    
    See Also