Skip to main content

TreeList.VirtualTreeGetCellValue Event

This event allows you to initialize cells (and optionally the check state) of the processed node, when populating the Tree List control with data dynamically.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v24.2.dll

Declaration

[DXCategory("VirtualTree")]
public event VirtualTreeGetCellValueEventHandler VirtualTreeGetCellValue

Event Data

The VirtualTreeGetCellValue event's data class is VirtualTreeGetCellValueInfo. The following properties provide information specific to this event:

Property Description
CellData Gets or sets the current cell value (when VirtualTreeGetCellValueInfo.IsCheckState is false) or the node’s check state (when VirtualTreeGetCellValueInfo.IsCheckState is true).
Column Gets the column that contains the cell currently being processed.
IsCheckState Gets whether the TreeList.VirtualTreeGetCellValue event/IVirtualTreeListData.VirtualTreeGetCellValue interface method is currently fired for you to provide a node’s check state.
Node Gets an instance of the business object being currently processed.

Remarks

For more information, see Virtual Mode (Dynamic Data Loading) Using Events (Tree List Level).

Example

The following demo shows how to use the TreeList.VirtualTreeGetChildNodes and TreeList.VirtualTreeGetCellValue events to specify data for a Tree List control.

Run Demo: Explorer(Virtual Tree)

The navigationTreeList control in this demo displays directories of the file system. Instead of loading the entire directory structure on application startup, this control loads directories on demand (when a user expands a specific directory).

Tree List - Virtual mode events

The TreeList.VirtualTreeGetChildNodes event is handled to dynamically load child items (directories) for a specific node. The Tree List control automatically creates nodes for all child items that the VirtualTreeGetChildNodes event handler supplies.

The TreeList.VirtualTreeGetCellValue event handler specifies values for loaded children.

navigationTreeList.VirtualTreeGetChildNodes += OnNavigationTreeListGetChildNodes;
navigationTreeList.VirtualTreeGetCellValue += OnNavigationTreeListGetCellValue;
//...
void OnNavigationTreeListGetChildNodes(object sender, VirtualTreeGetChildNodesInfo e) {
    Cursor current = Cursor.Current;
    Cursor.Current = Cursors.WaitCursor;
    e.Children = ((Item)e.Node).GetDirectories();
    Cursor.Current = current;
}

void OnNavigationTreeListGetCellValue(object sender, VirtualTreeGetCellValueInfo e) {
    e.CellData = ((Item)e.Node).DisplayName;
}

//...
public abstract class Item : IFileImage {
    //...
    public string DisplayName {get; private set;}
    public abstract List<Item> GetDirectories();
}

Handle the TreeList.VirtualTreeSetCellValue event for the opposite task: if the Tree List is editable, you can write new cell values entered by users to a data source.

using DevExpress.XtraTreeList;

void OnVirtualTreeSetCellValue(object sender, VirtualTreeSetCellValueInfo e) {
    ((Item)e.Node).DisplayName = e.NewCellData.ToString();
}

See the Explorer (Virtual Tree) demo for the complete code.

The following code snippets (auto-collected from DevExpress Examples) contain references to the VirtualTreeGetCellValue event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also