- 4 minutes to read
The Tree List control supports unbound mode, where you can manually create nodes. Unbound mode implies that the TreeList.DataSource property is set to null.
Adding Columns and Nodes in Unbound Mode
Follow the steps below to customize a Tree List control for use in unbound mode:
Use the TreeListColumn.UnboundType property to specify the data type for unbound columns.
Manually create nodes.
You can use the Nodes Editor to create nodes manually at design time. At runtime, use the TreeList.AppendNode method to create nodes.
To create a node in unbound mode, use the TreeList.AppendNode method. The method takes a nodeData parameter, and this specifies the data used to initialize the created node cells. This parameter value can be an array of values or a DataRow object. The number and order of items in the array/DataRow object must match the number and order of Tree List columns.
For examples on how to populate a Tree List control in unbound mode, see the following help topics:
There are two data loading approaches in unbound mode. The first approach - create all the nodes at one time (for instance, on form loading). The second approach is to create root nodes on form loading and then provide child nodes dynamically, on demand, when parent nodes are expanded. Implementation of dynamic detail loading improves application performance, and reduces the data stored in memory for each parent node.
You can implement dynamic loading as follows:
Create root nodes in a Tree List control.
You can use the TreeList.AppendNode method (for instance, on the application startup) to create root nodes.
For nodes that will have children, set the TreeListNode.HasChildren property to true.
Handle the TreeList.BeforeExpand event to create child nodes for the node being expanded.
For child nodes, you also need to set the TreeListNode.HasChildren property to true, if these nodes have their own children.
Export and Import Data
In unbound mode, you can export nodes and their data to a stream or file in XML format, and then load it later. To export the data, use the TreeList.ExportToXml method. To import the previously saved data, use the TreeList.ImportFromXml method.
For more information on data export, see the following help topic: Export and Import Data.
Working in Unbound Mode
Every time the TreeList.AppendNode method or another method that modifies the node structure is called, the Tree List control performs an update. If you perform multiple subsequent calls to these methods, multiple updates take place. For performance reasons, you can avoid unnecessary updates by enclosing your code with the TreeList.BeginUnboundLoad and TreeList.EndUnboundLoad methods. In this instance, the control is updated only once, by the EndUnboundLoad method.
The following topic refers to members that may be useful to you when performing operations on the Tree List control in unbound mode: Member Table: Unbound Mode.
Update Cell Values
Use the following methods to get and set cell values:
- TreeList.SetRowCellValue — Sets the TreeList cell to a specific value.
- TreeList.GetRowCellValue — Retrieves the value stored within the required cell.
- TreeList.GetRowCellDisplayText — Returns the text displayed by a specific Tree List cell.
To access nodes, use the following properties:
- TreeList.Nodes — Provides access to the collection of the TreeList's root nodes.
- TreeListNode.Nodes — Gets the collection of the node's children.
- TreeListNode.ParentNode — Gets the parent node of the current tree node.
You can also use the following methods to get a node:
- FindNodeByID — Returns the node specified by its identifier.
- FindNodeByKeyID — Returns the node by its key field value.
- FindNodeByFieldValue — Returns a node by its field value.
DevExpress controls support consistent UIs and APIs within similar features. You can use the same approach to get and set cell values in the Gantt Control, Data Grid, and Vertical Grid. These controls expose similar methods to get and set cell values.
- How to: Create Nodes in Unbound Mode at Design Time
- How to: Create Nodes in Unbound Mode in Code
- How to: Implement Virtual Mode (Dynamic Loading) in Unbound Mode