Back to Devexpress

TcxCustomSchedulerStorage.EndUpdate Method

vcl-cxschedulerstorage-dot-tcxcustomschedulerstorage-b04ace6e.md

latest4.6 KB
Original Source

TcxCustomSchedulerStorage.EndUpdate Method

Updates storage and releases a lock on the data controller.

Declaration

delphi
procedure EndUpdate;

Remarks

Every time you change scheduler storage settings, add/remove user events, resources, etc. – the storage component sends corresponding change notifications to associated components. Enclose multiple scheduler storage changes between BeginUpdate and EndUpdate calls to avoid redundant notifications and UI flickering in the associated TcxScheduler control.

BeginUpdate/EndUpdate Calls and Batch Changes

A BeginUpdate procedure call disables notifications and postpones all changes until an EndUpdate call. A subsequent EndUpdate call does the following:

  • Re-enables change notifications
  • Applies all changes made after a BeginUpdate call
  • Sends corresponding notifications in a batch
  • Redraws the associated TcxScheduler control

Note

Ensure that every BeginUpdate procedure call is followed by an EndUpdate procedure call, even if an exception occurs. Otherwise, the associated TcxScheduler control cannot interact with stored user events.

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:

delphi
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;
cpp
#include  // Declares the IncHour function
#include  // Declares the Now function
#include "cxScheduler.hpp" // Declares the TcxScheduler class
#include "cxSchedulerStorage.hpp" // Declares the TcxCustomSchedulerStorage class and related types
#include "cxSchedulerDBStorage.hpp" // Declares the TcxSchedulerDBStorage class

// Add the following linker directives to the corresponding CPP source file:
#pragma link "cxScheduler" // Required to use cxScheduler.hpp declarations
#pragma link "cxSchedulerStorage" // Required to use cxSchedulerStorage.hpp declarations
#pragma link "cxSchedulerDBStorage" // Required to use cxSchedulerDBStorage.hpp declarations

void __fastcall TMyForm::FormCreate(TObject *Sender)
{
  TcxSchedulerEvent* AEvent;
  cxSchedulerDBStorage1->BeginUpdate(); // Initiates the following batch change
  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
  }
}

See Also

TcxCustomSchedulerStorage Class

TcxCustomSchedulerStorage Members

cxSchedulerStorage Unit