[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications, and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Collapse]Tree List
   [Expand]Product Information
   [Collapse]Feature Center
    [Collapse]Data Binding
      Bound Mode
      Tree Generation Algorithm in the Tree List
      Virtual Mode (Dynamic Data Loading) Using Events (Tree List Level)
      Virtual Mode - Binding to a Hierarchical Business Object (Data Source Level)
      Unbound Mode
      Unbound Columns
      Posting Data to a Connected Database in ADO.NET
    [Expand]Data Editing
    [Expand]Data Presentation
    [Expand]Appearances and Look And Feel
    [Expand]Focus, Selection and Navigation
     Formatting Cell Values
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]End User Capabilities
   [Expand]Member Tables
  [Expand]Gantt Control
  [Expand]Chart Control
  [Expand]Map Control
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Unbound Columns

This page covers unbound columns, which help you display custom data within the Tree List control. These columns are not bound to fields in the data source, and data for these columns needs to be provided using expressions or a dedicated event.


Expanded Bound and Unbound Columns

There are two types of columns in the TreeList control: bound and unbound.

Bound columns obtain their data from a control's data source, which is specified by the TreeList.DataSource and TreeList.DataMember properties. These columns' TreeListColumn.FieldName properties refer to valid fields in the data source.

In some cases, the data source does not provide the values you wish to display in the Tree List. For instance, you may want to display a column whose values are calculated according to a formula based on values of other columns. Or you may want to display values in this column from a different data source. All these cases can be addressed by creating an unbound column. Data for this column needs to be specified manually, using one of the following two approaches.

  • By specifying a formula (string expression) using the TreeListColumn.UnboundExpression property used to automatically evaluate values for this column. Expressions allow you to calculate values based on values of other columns. You can use constants, various functions and operators in expressions. See Expressions to learn about the syntax.
  • By handling the TreeList.CustomUnboundColumnData event. In this event, you can implement custom logic of any complexity.

    With this event, you can enable an end-user to edit values in unbound columns. When an end-user modifies a cell, the CustomUnboundColumnData event fires, allowing you to save changes.


    The CustomUnboundColumnData event fires only for visible unbound columns.

To create an unbound column, add a TreeListColumn object to the TreeList.Columns collection and set the following column properties.




Set this property to a unique string that does not match any field name in the Tree List control's underlying data source.


Set this property to a value that identifies the type of data the column is supposed to display (Boolean, DateTime, Decimal, Integer, String or Object). Do not set the column's UnboundType property to UnboundColumnType.Bound, as this would identify the column as bound.

An unbound column's UnboundType property determines which default editor is used to represent column values. For example, if the UnboundType property is set to UnboundColumnType.DateTime, the column will use a DateEdit in-place editor. Second, this property's setting determines how cell values are aligned, and which sorting and validity rules are applied to the column.

Note that you can explicitly assign a specific editor to a column with the TreeListColumn.ColumnEdit property, and to a specific cell by handling the TreeList.CustomNodeCellEdit event.

After the column is created, implement logic for populating it with data, as described in the following section.

Expanded Unbound Columns' Data

You can provide data for unbound columns either by creating an expression using the TreeListColumn.UnboundExpression property, or by handling the TreeList.CustomUnboundColumnData event. To learn about the syntax of expressions, see Expressions.

At runtime, an end-user can edit an unbound column's expression using an Expression Editor. It can be opened using a context menu (if the TreeListColumn.ShowUnboundExpressionMenu option is enabled) or in code using the TreeList.ShowUnboundExpressionEditor method.

By default, data editing is enabled in unbound column cells. However, you may wish to prevent an end-user from editing unbound columns. To make a column read-only, the TreeListOptionsColumn.AllowEdit or TreeListOptionsColumn.ReadOnly options can be used.

If you wish to save the changes made by end-users in unbound columns, an unbound column should be populated with the TreeList.CustomUnboundColumnData event, but not using expressions. This event's IsGetData and IsSetData parameters determine the event's current mode of operation. If the IsGetData parameter is set to true (and consequently the IsSetData parameter is set to false), the event handler should supply data for the unbound column. A value should be assigned to the Value parameter according to the node currently being processed. The current node can be identified using the Node and Row parameters.

If the IsSetData parameter is set to true (and consequently the IsGetData parameter is set to false), the event has been fired as a result of data modifications within the Tree List. In this case, the Value parameter contains modified data and should be stored for further use.

Expanded Example

This example creates a "Change from Previous Year" read-only unbound column in the TreeList control and populates this column with data using the TreeList.CustomUnboundColumnData event.

Is this topic helpful?​​​​​​​