HypernovaDesktop Components · docs
Binarymission
WinForms › Project Management › TaskChangingEventArgs

TaskChangingEventArgs

class.NET 6 / 8 / 10.NET Framework 4.8Binarymission.WinForms.Controls.ProjectManagement

Provides data for the Gantt chart's GanttChart.TaskChanging event: a change the reader is about to make to one task, which a handler can inspect and refuse.

public class TaskChangingEventArgs : CancelEventArgs

Inherits from / implements: CancelEventArgs

Remarks

Each New... property is the value the task would take, or null when that value is not changing. The task itself has not changed yet: compare Task's properties with the new values to see what the reader did.

Set CancelEventArgs.Cancel to true to refuse the change; the bar, cell or row goes back to how it was and nothing is written to the task. Otherwise the chart calls Apply and every chart sharing the task redraws.

A move of a task whose length comes from its planned start and finish, rather than a ProjectTask.Duration, carries the length it was scheduled with as NewDuration too, so the task keeps its length when it moves.

Examples

gantt.TaskChanging += (sender, e) =>
{
    // Work that has been signed off stays where it is.
    if (e.Task.Status == "Done" && (e.NewStart.HasValue || e.NewDuration.HasValue))
    {
        e.Cancel = true;
        return;
    }

    // Nothing is planned to take longer than a quarter.
    if (e.NewDuration > 65)
        e.Cancel = true;
};

See also

Members at a glance

Constructors
TaskChangingEventArgsCreates the data for a proposed change to a task. The charts create these; an application needs to only in a test, or in a control of its own that follows the same pattern.
Properties
NewDurationGets the duration the task would take: the reader stretched or shortened it.
NewNameGets the name the task would take: the reader typed it.
NewProgressGets the progress the task would take: the reader dragged its progress or typed it.
NewStartGets the planned start the task would take: the reader moved it.
SourceGets how the change was made.
TaskGets the task that would change. It has not changed yet, so its properties still hold the old values.
Methods
ApplyWrites the new values to Task. The charts call this when no handler has cancelled the change.

Constructors

TaskChangingEventArgs

public TaskChangingEventArgs(ProjectTask task, TaskEditSource source, DateTime? newStart, int? newDuration, double? newProgress, string newName)

Creates the data for a proposed change to a task. The charts create these; an application needs to only in a test, or in a control of its own that follows the same pattern.

Parameters
task
The task that would change.
source
How the change was made.
newStart
The new planned start, or null when the start is not changing.
newDuration
The new duration in working days, or null.
newProgress
The new percentage complete, or null.
newName
The new name, or null.

Properties

NewDuration

public int? NewDuration

Gets the duration the task would take: the reader stretched or shortened it.

Value
Working days, or null when the duration is not changing.

NewName

public string NewName

Gets the name the task would take: the reader typed it.

Value
The new name, or null when the name is not changing.

NewProgress

public double? NewProgress

Gets the progress the task would take: the reader dragged its progress or typed it.

Value
A percentage from 0 to 100, or null when progress is not changing.

NewStart

public DateTime? NewStart

Gets the planned start the task would take: the reader moved it.

Value
A date with no time of day, or null when the start is not changing.

Source

public TaskEditSource Source

Gets how the change was made.

Task

public ProjectTask Task

Gets the task that would change. It has not changed yet, so its properties still hold the old values.

Methods

Apply

public void Apply()

Writes the new values to Task. The charts call this when no handler has cancelled the change.

Remarks

Only the values that are not null are written. Writing a new duration also clears the task's ProjectTask.Finish, unless its ProjectTask.Constraint is TaskConstraintKind.FinishNoEarlierThan, so that the planned finish and the duration never say two different things. It does not look at CancelEventArgs.Cancel.