Skip to main content

How to Determine the Time Interval Selected by an End-User

To implement this task, handle a scheduler’s OnSelectionChanged event. The event fires every time an end-user selects a time block in the scheduling area.

Within the event handler, use the scheduler’s SelFinish and SelStart properties to determine the selected interval’s bounds.

In the example, the currently selected interval is displayed in the TMemo edit control embedded into the scheduler’s control box.

// ...
procedure TForm1.cxScheduler1SelectionChanged(Sender: TObject);
var
  ASelStart, ASelFinish: TDateTime;
begin
  with TcxScheduler(Sender) do
  begin
    ASelStart := SelStart;
    ASelFinish := SelFinish;
  end;
  with Memo1.Lines do
  begin
    if Capacity > 0 then
      Clear;
    Add('Selected time interval:');
    Add(#13);
    Add(DateTimeToStr(ASelStart));
    Add(DateTimeToStr(ASelFinish));
  end;
end;

The following image shows the code execution result:

See Also