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
   [Expand]Feature Center
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Collapse]Examples
    [Collapse]Data Binding
      How to: Create Nodes in Unbound Mode at Design Time
      How to: Create Nodes in Unbound Mode in Code
      How to: Implement a Tree Structure for a Business Object
      How to: Implement Virtual Mode (Dynamic Loading) in Unbound Mode
      How to: Load Data Dynamically via Events
    [Expand]Nodes
    [Expand]Data Editing
    [Expand]Data Representation
    [Expand]Sorting
    [Expand]Summaries
    [Expand]Appearance
    [Expand]Focus and Selection
    [Expand]Miscellaneous
     How to: Drag XtraGrid rows to the XtraTreeList
     How to: Format a Column's Numeric Values as Currency
     How to: Hide Specific Nodes
     How to: Hide specific nodes using filter conditions
   [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]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]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

How to: Load Data Dynamically via Events

The example shows how to display information on directories and files on your system in a Tree List control dynamically, using only events. The full code for this example is available in the Explorer (Virtual Tree) module of the Tree List Main Demo. Here, only a part of the code is listed, giving you a basic understanding of how the Tree List events for dynamic loading work.

To provide data for the Tree List control, the TreeList.VirtualTreeGetChildNodes and TreeList.VirtualTreeGetCellValue events are handled. The first event is used to provide lists of root and child nodes. The second event is used to provide values for node cells. To save the changes made by an end-user to node cells, the TreeList.VirtualTreeSetCellValue event is handled. However, its implementation is omitted here. In this example, it's assumed that the Tree List control contains three columns, displaying a directory/file name, a directory flag and a file size. This data is provided via the VirtualTreeGetCellValue event.

To support dynamic data loading, the TreeList.DataSource property must be set to any custom object, except an IList object or an object implementing the IVirtualTreeListData interface. In the example, the DataSource property is set to a new Object instance.

The image below shows the result.

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