移動タスク

Microsoft Projectを使用すると、1つのタスクを別のタスクの下に移動できます。この場合、選択したタスクの子タスクも移動します。 .NETのAspose.Tasksは、別のタスクの下にタスクを移動することにより、同じ機能を提供します。これは、この記事に示すように、選択したタスクを新しい親の子供に追加することで実現できます。タスクは、別の親または同じ親の下で移動できます。

別の親の下にタスクを移動

1Project project = new Project("New Project.mpp");
2project.CalculationMode = CalculationMode.Automatic;
3// Get Tasks by Ids
4Task task1 = project.RootTask.Children.GetByUid(6);
5Task task2 = project.RootTask.Children.GetByUid(3);
6// Adding Task 6 to another parent
7task2.Children.Add(task1);
8project.Save("MoveTaskUnderAnotherParent_out.mpp", SaveFileFormat.MPP);

Moving Task Under the Same Parent

The MoveToSibling method allows moving a task under the same parent to a specific position.

1Project project = new Project("New Project.mpp");
2// Move tasks with id 5 before task with id 3
3Task task = project.RootTask.Children.GetById(5);
4task.MoveToSibling(3);
5project.Save("MoveTaskUnderSameParent_out.mpp", SaveFileFormat.MPP);

Add Task To The End

To add a task to the end of the collection use -1.

1Project project = new Project("New Project.mpp");
2// Move tasks with id 2 to the end of the collection
3Task task = project.RootTask.Children.GetById(2);
4task.MoveToSibling(-1);
5project.Save("MoveTaskAtTheEnd_out.mpp", SaveFileFormat.MPP);
Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.