Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

How to Create Tasks in Gantt View in Code

  • 2 minutes to read

The ExpressScheduler provides the following API that allows you to build a task plan in Gantt View programmatically:

The following example demonstrates how to create tasks in Gantt View using this API:

Delphi
// ...
var
  I: Integer;
  APreEvent, AEvent: TcxSchedulerEvent;
begin
  APreEvent := nil;
  for I := 1 to 10 do
  begin
    AEvent := Scheduler.Storage.createEvent;
    with AEvent do
    begin
      Caption := IntToStr(I);
      Start := Trunc(Date * 24) / 24;
      Duration := 1 / 24 + Trunc(RandomRange(1, 5)) / 24;
      TaskComplete := RandomRange(0, 100);
      Post;
      TaskLinks.Add(APreEvent, TcxSchedulerEventRelation(RandomRange(0, 3)));
    end;
    APreEvent := AEvent;
  end;
end;

The following image shows the code execution result:

The following image shows the task completion percentage (if the scheduler’s ViewGantt.EventsStyle property is esProgress):

See Also