在甘特图应用中,用代码设置前驱任务讲的很明白,但是对于一个已经设置好了的甘特图,如何在遍历甘特图任务时,用代码获取前驱任务?谢谢!
[此贴子已经被作者于2025/4/19 8:25:55编辑过]
我是要获取某一任务的前驱任务,不知道Predecessors集合是什么类型,如河遍历获取?试了几次不成功!
2楼帮助里有这个类型的用法,和普通集合一样遍历即可。新版代码编辑器里也很容易就看到各种类型呀
Dim gv As GanttView = Forms("窗口1").Controls("GanttView1").GanttView
Dim tk As Gantt.Task = gv.Tasks.Search("Task3")
If tk IsNot Nothing Then
Dim p As Gantt.Predecessor = tk.Predecessors(0)
Output.Show(p.PredecessorTask.Name)
For Each t As Gantt.Predecessor In tk.Predecessors
Output.Show(t.PredecessorTask.Name)
Next
End If