ComponentOne GanttView for WinForms
Loading GanttView From an XML File
GanttView for WinForms Task-Based Help > Saving and Loading GanttView as an XML File > Loading GanttView From an XML File

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

Load C1GanttView as an XML file at run time

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

  1. Click the Load From XML File icon in the C1GanttView toolbar.

    The Load From Xml File dialog box appears.
  2. Browse to the location you wish to load the xml file.
  3. Click Open in the Load From Xml File dialog box.

Load C1GanttView from XML file in code

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

To write code in Visual Basic

Visual Basic
Copy Code
Private Sub btnLoadXml_Click(sender As Object, e As EventArgs)
   Using dlg As 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 Then
             Try
                   ganttView.LoadXml(dlg.FileName)
             Catch
                   MessageBox.Show("Bad C1GanttView XML.", dlg.Title)
             End Try
      End If
   End Using
End Sub

To write code in C#

C#
Copy Code
private void btnLoadXml_Click(object sender, EventArgs e)
{
    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
            {
                ganttView.LoadXml(dlg.FileName);
            }
            catch
            {
                MessageBox.Show("Bad C1GanttView XML.", dlg.Title);
            }
        }
    }
}

In addition, you can load MS Project XML file in GanttView by using the ImportFromMsProjectXml method.

See Also