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 a XML, iCal, or binary (.dat) file. The Export method opens the SaveFileDialog dialog box allowing you to export a XML, iCal, or binary (.dat) file.

    Note: 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 Import and Export buttons. 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. Resize the form, and from the Visual Studio Toolbox add a SplitContainer control to the form.
    3. Click in the left pane of the SplitContainer and double-click the C1Calendar control in the Visual Studio Toolbox, to add it to the form.
    4. In the Properties window, set C1Calendar1.Dock property to Fill.
    5. Click in the right pane of the SplitContainer and double-click the C1Schedule control in the Visual Studio Toolbox, to add it to the form.
    6. In the Properties window, set C1Schedule1.Dock property to Fill.
    7. In the Properties window, set C1Calendar1.Schedule property to C1Schedule1.
    8. Click in the left pane of the SplitContainer and from the Visual Studio Toolbox add two Button controls to the form on top of the C1Calendar control.
    9. In the Properties window, set Button1's Text property to "Import" and set Button 2's Text property to "Export". Your form you look similar to the following:
             
    10. Double-click the Import button. The Code Editor will open and the Button1_Click event will be added.
    11. Add code to the Button1_Click event so that it looks like the following:
      C#
      Copy Code
      private void buttonImport_Click(object sender, EventArgs e)
      {
          c1Schedule1.Import("Import a File");
      }
      

      This will enable importing files.

    12. In Design view, double-click the Export button. The Code Editor will open and the Button2_Click event will be added.
    13. Add code to the Button2_Click event so that it looks like the following:
      C#
      Copy Code
      private void buttonExport_Click(object sender, EventArgs e)
      {
          c1Schedule1.Export("", "Export a File");
      }
      

      This will enable exporting files.

    Run your application and observe:

    The Import and Export buttons will enable you to import and export appointments into your scheduling application.

    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, iCal, or binary file. 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, iCal, or binary file.
    5. Import the myFile.xml file you just saved and observe that the appointments you added are restored in the schedule.