Skip to main content

GanttControl.CustomTaskProgress Event

Fires when a task’s progress is recalculated and allows you to specify a custom value.

Namespace: DevExpress.XtraGantt

Assembly: DevExpress.XtraGantt.v23.2.dll

NuGet Package: DevExpress.Win.Gantt

Declaration

[DXCategory("Events")]
public event CustomTaskProgressEventHandler CustomTaskProgress

Event Data

The CustomTaskProgress event's data class is CustomTaskProgressEventArgs. The following properties provide information specific to this event:

Property Description
Node Gets or sets the processed node.
Progress Gets or sets the task’s progress (a value from 0 to 1).

Remarks

If the UpdateDependentTaskProgress option is enabled, the control automatically recalculates the progress when changes are made. For example, when a user modifies a particular task’s progress, the control updates the progress of all dependent tasks:

  • for a regular task — the control recalculates the progress for all summary tasks (the total progress).

    Note that tasks contribute to the total progress in proportion to their duration. For example, a completed one-week task adds more to the total progress than a one-day task.

  • for a summary task (the total progress) — the control recalculates the progress for all sub-tasks and parent summary tasks.

    Note that the specified total progress is shared between sub-tasks in the order they appear in the time scale. For example, the specified progress is applied to the first task until it is complete and then the second task if there are two consecutive tasks. If there are two simultaneous tasks, the total progress is applied equally.

The CustomTaskProgress event fires when the control recalculated a dependent task’s progress. You can handle this event to specify a custom value.

If the UpdateDependentTaskProgress option is disabled or if you updated progress in the data source, the control does not update progress in dependent tasks. You can call the UpdateSummaryProgress method to update progress for all summary tasks in a tree branch that starts from the specified task. If the summary task is not specified, the method updates all tasks in the project.

See Task Progress for more information.

Example

The code below handles the CustomTaskProgress event to apply a coefficient to the contribution of a particular task to the total progress.

ganttControl1.CustomTaskProgress += GanttControl1_CustomTaskProgress;

private void GanttControl1_CustomTaskProgress(object sender, DevExpress.XtraGantt.CustomTaskProgressEventArgs e) {
    if(e.Node.HasChildren) {
        float result = 0;
        foreach(GanttControlNode node in e.Node.Nodes)
            result += (float)node["Progress"] / 100 * (float)node["ProgressCoefficient"];
        e.Progress = result;
    }
}
See Also