Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [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]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
      Virtual Mode by Binding to a Business Object
      Unbound Mode
      Unbound Columns
      Posting Data to a Connected Database in ADO.NET
    [Expand]Nodes
    [Expand]Data Editing
    [Expand]Data Representation
    [Expand]Sorting
    [Expand]Filtering
    [Expand]Summaries
    [Expand]Appearances and Look And Feel
    [Expand]Focus, Selection and Navigation
     Formatting Cell Values
    [Expand]Miscellaneous
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]Examples
   [Expand]End User Capabilities
   [Expand]Member Tables
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap 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]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Virtual Mode by Binding to a Business Object

The TreeList control can be bound to a business object that encapsulates a tree structure. If the business object implements the DevExpress.XtraTreeList.IVirtualTreeListData interface, the TreeList will function in Virtual Mode, in which nodes will be created on demand based on the data provided by the IVirtualTreeListData interface. For example, child nodes will only be created when you expand a certain parent node. More information on this interface is given below.

Expanded Concepts

The steps of binding to a business object are:

  1. create columns in the TreeList.Columns collection or using the Tree List Designer;
  2. implement the DevExpress.XtraTreeList.IVirtualTreeListData interface for the business object.

    The methods of this interface allow you to provide data for node creation. In addition, you can implement a dedicated method to save changes made by an end-user while editing node cells back to your business object.

The DevExpress.XtraTreeList.IVirtualTreeListData interface is defined as follows.

  • The VirtualTreeGetChildNodes method

    This method must provide a list of child objects for the current object. The number of objects returned by the method's info.Children list identifies the number of nodes that will be created. However, note that data for node cells must be provided by the VirtualTreeGetCellValue method.

  • The VirtualTreeGetCellValue method

    This method must provide data for node cells (and optionally provide node check states - see the Node Check States section below to learn more). The currently processed cell is identified by the method's info.Column parameter. To provide data, assign it to the info.CellData parameter.

  • The VirtualTreeSetCellValue method

    Implement this method if you need to save changes made by an end-user while editing node cells and node check states. The method provides the info.NewCellData parameter that represents the new value. Typically, you need to save this value to your business object. However, you can discard the value. To do this, set the info.Cancel parameter to true.

You can use the TreeList.EnableDynamicLoading property to specify whether a node hierarchy is created dynamically (on node expansion) or all at once on initial loading.

Expanded Node Check States

You can use the TreeListOptionsView.ShowCheckBoxes property to enable built-in check boxes that allow end-users to check certain nodes. In this case, you can set the TreeListOptionsBehavior.AllowBoundCheckBoxesInVirtualMode property to true to use the IVirtualTreeListData.VirtualTreeGetCellValue and VirtualTreeSetCellValue methods to specify not only node values, but also node check states.

When the TreeListOptionsBehavior.AllowBoundCheckBoxesInVirtualMode property is true, the IVirtualTreeListData.VirtualTreeGetCellValue interface method will be additionally fired for each node with the VirtualTreeGetCellValueInfo.IsCheckState parameter set to true. To provide a node's check state, assign it to the VirtualTreeGetCellValueInfo.CellData parameter (when IsCheckState is true). Similarly, when an end-user modifies a node's check state, the IVirtualTreeListData.VirtualTreeSetCellValue interface method will be fired with the VirtualTreeSetCellValueInfo.IsCheckState parameter set to true. In this case, save the node's check state (which is stored in the VirtualTreeSetCellValueInfo.NewCellData parameter) according to your logic.

Expanded Task-Based Help

How would you rate this topic?​​​​​​​