TreeList.VirtualTreeSetCellValue Event
Allows changes that are made to node cells and check state to be stored.
Namespace: DevExpress.XtraTreeList
Assembly: DevExpress.XtraTreeList.v24.2.dll
Declaration
[DXCategory("VirtualTree")]
public event VirtualTreeSetCellValueEventHandler VirtualTreeSetCellValue
Event Data
The VirtualTreeSetCellValue event's data class is VirtualTreeSetCellValueInfo. The following properties provide information specific to this event:
Property | Description |
---|---|
Cancel | Gets or sets whether the new value is discarded. |
Column | Gets the column that contains the cell being currently processed. |
IsCheckState | Gets whether the TreeList.VirtualTreeGetCellValue event/IVirtualTreeListData.VirtualTreeGetCellValue interface method is currently fired for you to save a node’s check state. |
NewCellData | Gets the new cell value (when VirtualTreeSetCellValueInfo.IsCheckState is false) or the node’s new check state (when VirtualTreeSetCellValueInfo.IsCheckState is true). |
Node | Gets an instance of the business object being currently processed. |
OldCellData | Gets the current cell’s old data. |
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.
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).
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.