When using TMSFNCGantt, if I create a parent task ( MainTask ) with both PlannedStart and PlannedEnd set, then add a single child task ( subTask ), the Gantt chart ignores the parent’s PlannedStart/PlannedEnd and instead adopts the dates from the child task.
Initial value setting
// initial value setting
procedure TForm1.FormShow(Sender: TObject); // date value setting
begin
TMSFNCGanttChart1.Project.Tasks.Clear;
mainDtStart := IncDay(Now, 0); // public var
mainDtEnd := incDay(mainDTStart,5); // public var
subDtStart := IncDay(mainDtStart,10); // mainDtStart + 3
subDtEnd := incDay(subDtStart,15); // mainDtEnd + 3
end;
After adding only the parent task
procedure TForm1.SpeedButton1Click(Sender: TObject);
begin
TMSFNCGanttChart1.BeginUpdate;
mainT := TMSFNCGanttChart1.Project.AddTask('MainTask','MainTask');
mainT.PlannedStart := mainDtStart;
mainT.PlannedEnd := mainDtEnd;
TMSFNCGanttChart1.EndUpdate;
end;
After adding the child task
procedure TForm1.SpeedButton2Click(Sender: TObject);
begin
TMSFNCGanttChart1.BeginUpdate;
subT := mainT.AddSubTask('subTask','subTask');
subT.PlannedStart := subDtStart;
subT.PlannedEnd := subDtEnd;
TMSFNCGanttChart1.EndUpdate;
end;
Is there a way to prevent the parent task’s PlannedStart and PlannedEnd from being overwritten on the Gantt chart?
In Microsoft Project this would be equivalent to setting the parent task’s mode to Manual.
In our workflow, managers create the parent tasks while individual team members add their own child tasks, so it is crucial for us to detect whenever a sub-task’s PlannedStart or PlannedEnd falls outside the parent task’s date range.