All docs
V20.1
20.2 (EAP/Beta)
20.1
19.2
The page you are viewing does not exist in version 19.2. This link will take you to the root page.
19.1
The page you are viewing does not exist in version 19.1. This link will take you to the root page.
18.2
The page you are viewing does not exist in version 18.2. This link will take you to the root page.
18.1
The page you are viewing does not exist in version 18.1. This link will take you to the root page.
17.2
The page you are viewing does not exist in version 17.2. This link will take you to the root page.

Task Progress

  • 4 minutes to read

A task's progress is a value that indicates the percentage of work completed. In the chart, a task displays the completed and upcoming work in different colors.

Bind to Data

You can store a task's progress in a data source. The DataSource property specifies the data source bound to the control. Use the ProgressFieldName property to specify the field in the data source that stores each task's progress. The type of the data field should be Single and contain values from 0 to 100.

ganttControl1.ChartMappings.ProgressFieldName = "Progress";

See Data Source for more information on how to bind the control to a data source.

Edit Task Progress

The control generates columns in the task list for all fields in the bound data source. A user can use the column editor to update a task's progress in a cell. You can substitute the default TextEdit control. For example, assign the SpinEdit control to the column. You can also apply the corresponding input mask to the editor to display and edit the value as a percentage.

RepositoryItemSpinEdit editor = new RepositoryItemSpinEdit();
editor.Mask.EditMask = "P";
editor.Mask.UseMaskAsDisplayFormat = true;
progressColumn.ColumnEdit = editor;

Enable the AllowModifyProgress option to allow users to modify the progress in the chart. You can also hide the Progress column in the task list.

progressColumn.Visible = false;
ganttControl1.OptionsCustomization.AllowModifyProgress = DefaultBoolean.True;

See Interactive Editing and Automatic Scheduling for more information.

Edits in Code

To specify the progress in code, use a GanttControlNode object's indexer. You can also use the GetProgress() method to get the value.

// Get the value.
float progress = (float)node.GetProgress();
float progress1 = (float)node.GetValue(progressColumn);
float progress2 = (float)node["Progress"];
// Set the value.
node.SetValue(progressColumn, 100);
node["Progress"] = 100;

Automatically Recalculate Task Progress

If the UpdateDependentTaskProgress option is enabled, the control automatically recalculates the progress when changes are made. That is, when a user modifies a particular task's progress, the control updates the progress in 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.

If the UpdateDependentTaskProgress option is disabled or if you updated the progress in the data source, the control does not update the progress in dependent tasks. You should call the UpdateSummaryProgress method to update the 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.

Adjust Recalculated Task Progress

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

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;
    }
}