GanttControl.GetSuccessorNodes(GanttControlNode) Method
Returns the specified node’s successors as GanttControlNode objects.
Namespace: DevExpress.XtraGantt
Assembly: DevExpress.XtraGantt.v24.2.dll
Declaration
Parameters
Name | Type | Description |
---|---|---|
node | GanttControlNode | An object that specifies a node. |
Returns
Type | Description |
---|---|
IEnumerable<GanttControlNode> | A collection of GanttControlNode objects. |
Remarks
Use the methods below to obtain a task’s successors. You can use a GanttControlNode object or Id property value to specify the task.
GetSuccessorNodes(GanttControlNode)
, GetSuccessorNodes(Int32), and GetSuccessorNodes() - return an IEnumerable<T> collection of GanttControlNode objects that specify a task’s successors.If the control is bound to a data source, these methods are not in effect if you call them before the control is displayed onscreen because nodes are not created yet. You can call the ForceInitialize() method to force node creation.
GetSuccessors(GanttControlNode), GetSuccessors(Int32), and GetSuccessors() - return keys (see KeyFieldName) of a task’s successors.
If you use the DependencySource property to specify dependencies, the returned value is a List<T> of keys as they are specified in the data source (see SuccessorFieldName).
If you use the DataSource property to specify dependencies, you cannot get successors because this data source stores predecessors only.
Use the methods below to obtain a task’s predecessors. You can use a GanttControlNode object or Id property value to specify the task.
GetPredecessorNodes(GanttControlNode), GetPredecessorNodes(Int32), and GetPredecessorNodes() - return an IEnumerable<T> collection of GanttControlNode objects that specify a task’s predecessors.
If the control is bound to a data source, these methods are not in effect if you call them before the control is displayed onscreen because nodes are not created yet. You can call the ForceInitialize() method to force node creation.
GetPredecessors(GanttControlNode), GetPredecessors(Int32), and GetPredecessors() - return keys (see KeyFieldName) of a task’s predecessors.
If you use the DependencySource property to specify dependencies, the returned value is a List<T> of keys as they are specified in the data source (see PredecessorFieldName).
If you use the DataSource property to specify dependencies, the returned value is an object as it is specified in the data source (see PredecessorsFieldName).
Example
The example below shows how to get a task’s predecessors and successors. You can use the FindNodeByFieldValue(String, Object) method to retrieve a GanttControlNode object by the content in a specific field.
using DevExpress.XtraGantt;
using System.Collections.Generic;
// The following methods return nodes that specify a task's predecessors and successors.
IEnumerable<GanttControlNode> predecessorNodes =
ganttControl1.GetPredecessorNodes(0);
IEnumerable<GanttControlNode> predecessorNodes1 =
ganttControl1.GetPredecessorNodes(ganttControl1.FindNodeByFieldValue("Text", "Task 2") as GanttControlNode);
IEnumerable<GanttControlNode> predecessorNodes2 =
(ganttControl1.FindNodeByFieldValue("Text", "Task 3") as GanttControlNode).GetPredecessorNodes();
IEnumerable<GanttControlNode> successorNodes =
ganttControl1.GetSuccessorNodes(0);
IEnumerable<GanttControlNode> successorNodes1 =
ganttControl1.GetSuccessorNodes(ganttControl1.FindNodeByFieldValue("Text", "Task 2") as GanttControlNode);
IEnumerable<GanttControlNode> successorNodes2 =
(ganttControl1.FindNodeByFieldValue("Text", "Task 3") as GanttControlNode).GetSuccessorNodes();
// The following methods return keys
// (as they are specified in the data source) of a task's predecessors and successors.
// If you use the DependencySource property to specify dependencies,
// the returned value is of List<object> type. Items in the collection are keys of the corresponding type.
List<object> predecessorKeyList =
ganttControl1.GetPredecessors(0) as List<object>;
List<object> predecessorsKeyList1 =
ganttControl1.GetPredecessors(ganttControl1.FindNodeByFieldValue("Text", "Task 2") as GanttControlNode) as List<object>;
List<object> predecessorsKeyList2 =
(ganttControl1.FindNodeByFieldValue("Text", "Task 3") as GanttControlNode).GetPredecessors() as List<object>;
List<object> successorKeyList =
ganttControl1.GetSuccessors(0) as List<object>;
List<object> successorsKeyList1 =
ganttControl1.GetSuccessors(ganttControl1.FindNodeByFieldValue("Text", "Task 2") as GanttControlNode) as List<object>;
List<object> successorsKeyList2 =
(ganttControl1.FindNodeByFieldValue("Text", "Task 3") as GanttControlNode).GetSuccessors() as List<object>;
// If you use the DataSource property to specify dependencies,
// the returned value is of the same type as in the data source.
// Note that you cannot get successors in this case
// since the data source stores predecessors only.
var predecessorKeys =
ganttControl1.GetPredecessors(0);
var predecessorsKeys1 =
ganttControl1.GetPredecessors(ganttControl1.FindNodeByFieldValue("Text", "Task 2") as GanttControlNode);
var predecessorsKeys2 =
(ganttControl1.FindNodeByFieldValue("Text", "Task 3") as GanttControlNode).GetPredecessors();