TdxGanttControlTaskDragAndDropEvent Type
Performs a set of actions during task row rearrangement in the Chart View‘s task sheet.
Declaration
TdxGanttControlTaskDragAndDropEvent = procedure(Sender: TObject; ATask: TdxGanttControlTask; ANewID: Integer; var AAccept: Boolean) of object;
Parameters
Name | Type | Description |
---|---|---|
Sender | TObject | The Chart View that raised the event. |
ATask | TdxGanttControlTask | A task that a user drags. |
ANewID | Integer | A new ID of the task. |
AAccept | Boolean | If True, a user can drop the dragged sheet row that corresponds to a task. If False, the operation is declined. |
Remarks
You can open the Features Demo and modify its code. The code snippet below shows how to handle the OnTaskDragDrop event to allow users to rearrange tasks in their summary task:
procedure TFeaturesDemoMainForm.GanttControlViewChartOptionsSheetTaskDragAndDrop(
Sender: TObject; ATask: TdxGanttControlTask; ANewID: Integer; var AAccept: Boolean);
function GetSummaryID(ATaskID: Integer): Integer;
var
I: Integer;
AChild: TdxGanttControlTask;
begin
Result := 0;
ATaskID := Min(ATaskID, GanttControl.DataModel.Tasks.Count - 1);
AChild := GanttControl.DataModel.Tasks[ATaskID];
if AChild.OutlineLevel = 0 then
Exit;
for I := AChild.ID - 1 downto 0 do
if (GanttControl.DataModel.Tasks[I].Summary) and (GanttControl.DataModel.Tasks[I].OutlineLevel = AChild.OutlineLevel - 1) then
Exit(I);
end;
begin
inherited;
AAccept := GetSummaryID(ATask.ID) = GetSummaryID(ANewID);
end;
See Also