Scheduler for WinForms | ComponentOne
Scheduler Control / Import and Export
In This Topic
    Import and Export
    In This Topic

    You can add importing and exporting functionality to your scheduling application using the Import and Export methods. The Import method opens the OpenFileDialog dialog box, allowing you to import an XML or iCal file. The Export method opens the SaveFileDialog dialog box, allowing you to export an XML or iCal file. Additionally, you can manually select or enter *.dat format to open or save files from OpenFileDialog or SaveFileDialog dialog boxes.

    Note: In .NET 9, the binary format (.dat) is not supported, and therefore hidden by default in OpenFileDialog and SaveFileDialog. You can also use built-in importing and exporting features, see Importing and Exporting Data for details.

    In the following example, C1Calendar and C1Schedule controls are added to the form along with two buttons named Import and Export. When the application is run, you'll be able to import and export data into the C1Schedule control.

    Complete the following steps to add importing and exporting functionality to a scheduling application:

    1. Create a new .NET application.
    2. From the toolbox, drag and drop the C1Calendar, C1Scheduler, and two Buttons onto the form.
    3. In the Properties window, set the Name and Text properties for buttons. In this example code, the Name property of first button is set to "buttonImport" and the Text property to "Import". Similarly, the Name property of second button is set to "buttonExport" and the Text property to "Export".

      The below image illustrates the sample layout of the form after placing all the controls:

    4. Double-click the Import button. The Code Editor will open and the buttonImport_Click event will be added. Add the below code to enable importing files:
      C#
      Copy Code
      private void buttonImport_Click(object sender, EventArgs e)
      {
          c1Schedule1.Import("Import a File");
      }
      
    5. Double-click the Export button. The Code Editor will open and the buttonExport_Click event will be added. Add the below code to enable exporting files:
      C#
      Copy Code
      private void buttonExport_Click(object sender, EventArgs e)
      {
          c1Schedule1.Export("", "Export a File");
      }
      

    Run your application:

    The Import and Export buttons will enable you to import and export appointments into your scheduling application. To Import and Export appointments from the application, perform the following tasks:

    1. Add a few appointments to the schedule.
    2. Click the Export button. The Export a File dialog box will open enabling you to export a XML or iCal file. For example, export the file as an XML file and name it "myFile.xml".
    3. Delete the appointments that you just added to the schedule.
    4. Click the Import button. The Import a File dialog box will open enabling you to import a XML or iCal file.
    5. Import the myFile.xml file you just saved and observe that the appointments you added are restored in the schedule.