Skip to main content
A newer version of this page is available. .

Unbound Mode

  • 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.

Online Video

WinForms Tree List - How to Create a Conventional TreeList.

Adding Columns and Nodes in Unbound Mode

Follow the steps below to customize a Tree List control for use in unbound mode:

  1. Create columns.

    You can use the Tree List Designer to create columns at design time, or utilize the TreeList.Columns collection to generate them in code.

    Use the TreeListColumn.UnboundType property to specify the data type for unbound columns.

  2. 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:

Dynamic Loading

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:

  1. 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.

  2. For nodes that will have children, set the TreeListNode.HasChildren property to true.

    The result is that an expand button is displayed for every node of this kind. When an end user clicks this button, the TreeList.BeforeExpand event fires.

  3. 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:

To access nodes, use the following properties:

You can also use the following methods to get a node:

Tip

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.

Examples

See Also