[Expand]General Information
[Collapse]WinForms Controls
 [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]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)

Tree Generation Algorithm in the Tree List

The Tree List control displays hierarchical data structures in which nodes can have other nodes as children. This topic shows how to define the parent-child relationship at data source level for Tree List controls in Bound Mode.

Expanded Parent-Child Relationships

The data source bound to the Tree List control requires two additional fields:

  • Key Field - This field contains unique values that identify records in the data source. Assign this field name to the TreeList.KeyFieldName property.
  • Parent Field - This field refers to a corresponding parent node's Key Field. Assign this field name to the TreeList.ParentFieldName property

The image below is an example of a data source with an ID column that contains Key Fields. The PARENTID column values are Parent Fields, which identify parent rows.

The following image shows the same data source bound to the Tree List control. The TreeList.KeyFieldName property is set to "ID" and the TreeList.ParentFieldName property to "PARENTID".

Expanded Root Nodes

Root nodes do not have parent nodes (for example, the "Corporate Headquarters" node in the image above). To identify root nodes in the data source, set their Parent Field values to 0, null or DBNull.Value. You can also use a custom Parent Field value to identify root nodes by assigning this value to the TreeList.RootValue property.

A record is also recognized as a root record if its TreeList.ParentFieldName field does not match any of the nodes' key field values and is not equal to the RootValue.



Related API * TreeList.KeyFieldName - Gets or sets the name of the key field that uniquely identifies records in the data source.

Expanded See Also

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