Tsk.ConstraintType field

Provides choices for the type of constraint that can be applied for scheduling a task.

public static readonly Key<ConstraintType, TaskKey> ConstraintType;


Shows how to get/set a constraint for a task.

var project = new Project(DataDir + "ConstraintAsLateAsPossible.mpp");

// Set constraint As Late As Possible for task with Id 11
var newTask = project.RootTask.Children.GetById(11);
newTask.Set(Tsk.ConstraintType, ConstraintType.AsLateAsPossible);

var collector = new ChildTasksCollector();
TaskUtils.Apply(project.RootTask, collector, 0);

// Parse through all the collected tasks
foreach (var task in collector.Tasks)
    Console.WriteLine(task.Get(Tsk.ConstraintDate).ToShortDateString() == "1/1/2000" ? "NA" : task.Get(Tsk.ConstraintDate).ToShortDateString());

SaveOptions options = new PdfSaveOptions
    StartDate = project.Get(Prj.StartDate),
    Timescale = Timescale.ThirdsOfMonths

project.Save(OutDir + "SetConstraintAsLateAsPossible_out.pdf", options);

See Also