Skip to main content
A newer version of this page is available. .

Unbound Mode

  • 2 minutes to read

This topic describes how to persist the data in Unbound Mode – in this mode the data is stored in a file system. To enable the scheduler to work in Unbound Mode, bind the TcxSchedulerStorage component to the scheduler control using the TcxScheduler.Storage property. The example in this topic is for demonstration purposes only. Using resources, as shown in the examples, is optional. To learn how to persist data in a database, refer to the Bound Mode help topic.

Consider an example where an application allows an end-user to schedule user events under different resources and saves the data to a file to work with it in multiple sessions.

  1. First, define schedule resources:

Using the Object Inspector, invoke the collection editor by clicking the ellipsis button next to the TcxSchedulerStorageResources.Items property, create two resources, name them and set the TcxSchedulerStorageResourceItem.ResourceID property to 1 and 2, respectively, for the first and second resource, as shown in the image below:

  1. Next, handle the TCustomForm.OnCreate and TCustomForm.OnDestroy events to use the data across multiple sessions, as shown in the following example:
// ...
procedure TUnboundForm.FormCreate(Sender: TObject);
const
  DlgMsg = 'There was no file found';
  FileName = 'c:\unbound.dat';
begin
  if FileExists(FileName) then
    // load the data from the file when the application starts up
    Storage.LoadFromFile(FileName)
  else
    ShowMessage(DlgMsg);
end;
procedure TUnboundForm.FormDestroy(Sender: TObject; var Action: TCloseAction);
const
  FileName = 'c:\unbound.dat';
begin
  // save the data to the file when the application exits
  Storage.SaveToFile(FileName);
end;

Now the application is ready to run. An end-user can create any user events that will be stored in the file:

The following example shows how to schedule the user event, which will be stored in the file, programmatically:

// ...
   with Storage.CreateEvent do
    begin
      // assign the newly created user event to the Nata Epelman resource
      ResourceID := 2;
      // specify the subject
      Caption := 'Anniversary';
      // this is the all-day event
      AllDayEvent := True;
      // synchronize with storage
      Post;
    end;

The image below shows the all-day event created under the Nata Epelman resource when the code is being executed:

See Also