Skip to main content

TcxCustomSchedulerStorage.createEvent Method

Creates a user event with the default settings and adds the event to the storage component.

Declaration

function createEvent: TcxSchedulerEvent; virtual;

Returns

Type Description
TcxSchedulerEvent

The created user event.

Remarks

Call the createEvent function to create a new user event and add it to the storage component.

To update content displayed in the associated TcxScheduler control, call the PostEvents procedure. All posted events are accessible through the Events property.

You can call the Clear procedure to delete all events in the storage component. To delete an individual user event, call its Delete procedure.

Code Example: Create User Events

The following code example creates, configures, and displays two events in a TcxScheduler control using a TcxSchedulerDBStorage component as user event storage:

uses
  System.SysUtils,  // Declares the Now function
  System.DateUtils,  // Declares the IncHour function
  cxScheduler,  // Declares the TcxScheduler class
  cxSchedulerStorage,  // Declares the TcxCustomSchedulerStorage class and related types
  cxSchedulerDBStorage;  // Declares the TcxSchedulerDBStorage class
// ...

procedure TMyForm.FormCreate(Sender: TObject);
var
  AEvent: TcxSchedulerEvent;
begin
  cxSchedulerDBStorage1.BeginUpdate;  // Initiates the following batch operation
  try
    AEvent := cxSchedulerDBStorage1.createEvent;
    AEvent.Caption := 'Event1';
    AEvent.Start := Now;
    AEvent.Finish := IncHour(Now, 2);
    AEvent.ResourceID := 1;

    AEvent := cxSchedulerDBStorage1.createEvent;
    AEvent.Caption := 'Event2';
    AEvent.Start := IncHour(Now, 3);
    AEvent.Finish := IncHour(Now, 5);
    AEvent.ResourceID := 1;

    cxSchedulerDBStorage1.PostEvents;  // Publishes created and configured user events
  finally
    cxSchedulerDBStorage1.EndUpdate;  // Calls EndUpdate regardless of the batch operation's success
  end;
end;

VCL Scheduler: User Event Creation Example

See Also