TaskChangingEventArgs
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 | |
|---|---|
TaskChangingEventArgs | 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. |
| Properties | |
NewDuration | Gets the duration the task would take: the reader stretched or shortened it. |
NewName | Gets the name the task would take: the reader typed it. |
NewProgress | Gets the progress the task would take: the reader dragged its progress or typed it. |
NewStart | Gets the planned start the task would take: the reader moved it. |
Source | Gets how the change was made. |
Task | Gets the task that would change. It has not changed yet, so its properties still hold the old values. |
| Methods | |
Apply | Writes the new values to Task. The charts call this when no handler has cancelled
the change. |
Constructors
TaskChangingEventArgs
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
nullwhen 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
Gets the duration the task would take: the reader stretched or shortened it.
- Value
- Working days, or
nullwhen the duration is not changing.
NewName
Gets the name the task would take: the reader typed it.
- Value
- The new name, or
nullwhen the name is not changing.
NewProgress
Gets the progress the task would take: the reader dragged its progress or typed it.
- Value
- A percentage from 0 to 100, or
nullwhen progress is not changing.
NewStart
Gets the planned start the task would take: the reader moved it.
- Value
- A date with no time of day, or
nullwhen the start is not changing.
Source
Gets how the change was made.
Task
Gets the task that would change. It has not changed yet, so its properties still hold the old values.
Methods
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.