Defining Link Type
Contents
[
Hide
Show
]The LinkType property exposed by the TaskLink class is used to retrieve or define the type of link between two tasks. It reads and writes one of the values defined by the TaskLinkType enumeration type.
Defining Link Type
To define link type in Microsoft Project: On the View menu, select More Views and then Task Entry Form.
- Double-click the desired task.
- Select the Predecessor tab.
Defining link type in Microsoft Project
Setting Link Type with Aspose.Tasks
The code sample given below set a link type as “Start-to-Start”, the default link type is “Finish-to-Start”.
1// Create new project and add tasks
2System::SharedPtr<Project> project = System::MakeObject<Project>();
3System::SharedPtr<Task> pred = project->get_RootTask()->get_Children()->Add(u"Task 1");
4System::SharedPtr<Task> succ = project->get_RootTask()->get_Children()->Add(u"Task 2");
5
6// Link tasks with link type set to Start to Start
7System::SharedPtr<TaskLink> link = project->get_TaskLinks()->Add(pred, succ);
8link->set_LinkType(Aspose::Tasks::TaskLinkType::StartToStart);
Getting Link Type with Aspose.Tasks
The code sample given below display link types by traversing the task links in the project and printing the result to a console window.
1// Create project instance
2System::String dataDir = RunExamples::GetDataDir(System::Reflection::MethodBase::GetCurrentMethod(ASPOSE_CURRENT_FUNCTION)->get_DeclaringType().get_FullName());
3System::SharedPtr<Project> project1 = System::MakeObject<Project>(dataDir + u"GetTaskLinkType.mpp");
4
5// Display task link types
6auto allinks = project1->get_TaskLinks();
7
8{
9 auto tsklnk_enumerator = (allinks)->GetEnumerator();
10 decltype(tsklnk_enumerator->get_Current()) tsklnk;
11 while (tsklnk_enumerator->MoveNext() && (tsklnk = tsklnk_enumerator->get_Current(), true))
12 {
13 System::Console::WriteLine(System::ObjectExt::ToString(tsklnk->get_LinkType()));
14 }
15}