[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]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)

Virtual Mode (Dynamic Data Loading) Using Events (Tree List Level)

The Tree List control supports dynamic data loading using events. You can handle specific events to provide data for the Tree List control dynamically, and save changes made by an end-user to cells, if required.

The basic steps to implement dynamic data loading are as follows.

  1. Create required columns that will display your data. You can do this at both design time and in code by modifying the TreeList.Columns collection.
  2. Specify the TreeList.DataSource property. Do not assign objects of the following types to this property.

    • Objects that implement the IList interface. In this case, the Tree List control will switch to bound mode and populate nodes automatically.
    • Objects that implement the IVirtualTreeListData interface. Otherwise, the Tree List control will fetch data from this object.
  3. By default, a node hierarchy is created dynamically (on node expansion). To change this behavior and create the entire node hierarchy at once, set the TreeList.EnableDynamicLoading property to false.
  4. Handle the TreeList.VirtualTreeGetChildNodes event. This event is used to supply lists of objects to be represented as nodes. The event fires dynamically on demand (for instance, when end-users expand nodes). The event's Node parameter identifies the parent object whose child nodes must be retrieved using the event. Set the event's Children parameter to create the required amount of child nodes for this parent node.

    The VirtualTreeGetChildNodes event also fires to retrieve objects representing root nodes. To identify this situation, check the Node parameter. It will refer to the object assigned to the TreeList.DataSource property.

  5. Handle the TreeList.VirtualTreeGetCellValue event to provide data for blank node cells and node check states (see the Node Check States section below). The event fires dynamically for each node object supplied by the TreeList.VirtualTreeGetChildNodes event and for each Tree List column. You can use the event's Node parameter to identify the underlying object and fetch the required data, if necessary. The currently processed Tree List column is specified by the Column parameter. To supply data, assign it to the event's CellData parameter.
  6. Handle the TreeList.VirtualTreeSetCellValue event, if you need to respond to changing node cells and check states by an end-user, and save this data. The event provides parameters to identify the current node cell. It also contains the Cancel parameter that allows you to discard a value entered by an end-user.

Expanded Node Check States

The TreeList nodes can display check boxes that allow end-users to check certain nodes (see Node Checking - Checkboxes and Radio Buttons). By default, the TreeList.VirtualTreeGetCellValue event is used to supply node values. If the TreeListOptionsBehavior.AllowBoundCheckBoxesInVirtualMode option is enabled, this event is also fired, so you provide a node's check state. Read the IsCheckState parameter to learn if the event is fired to query a check state. If it returns true, assign the check state to the event's CellData parameter.

Similarly, when an end-user modifies a node's check state, the TreeList.VirtualTreeSetCellValue event fires (if the TreeListOptionsBehavior.AllowBoundCheckBoxesInVirtualMode option is enabled) with the IsCheckState parameter set to true. In this case, you can save the node's new check state (which is stored in the NewCellData parameter) according to your logic.

Expanded Example

Expanded See Also

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