Skip to main content

TreeList.BeforeExpand Event

Fires before a node is expanded. Allows you to implement dynamic node loading in unbound mode.

Namespace: DevExpress.XtraTreeList

Assembly: DevExpress.XtraTreeList.v24.1.dll

NuGet Packages: DevExpress.Win.Navigation, DevExpress.Win.TreeList

Declaration

public event BeforeExpandEventHandler BeforeExpand

Event Data

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

Property Description
CanExpand Gets or sets whether a Tree List node can be expanded.
Node Gets the current Tree List node. Inherited from NodeEventArgs.

Remarks

Nodes that have child nodes can be expanded/collapsed to show/hide their children. You can use the TreeListNode.Expanded property of a node to control its state. The TreeList.ExpandAll, TreeList.ExpandToLevel and TreeListNode.ExpandAll methods also make use of this property to perform their task.

When a node is about to be expanded, the BeforeExpand event fires.

The BeforeExpand event also fires when expanding a node that does not have child nodes, provided that its TreeListNode.HasChildren property is set to true. Use the HasChildren property and BeforeExpand event to implement dynamic node loading in unbound mode. This load mode implies that only root-level nodes are initially created. Child nodes are loaded dynamically when their parent node is about to be expanded (using the BeforeExpand event). Please refer to the How to: Implement Virtual Mode (Dynamic Loading) in Unbound Mode topic, for an example.

You can also use the BeforeExpand event to specify whether the processed node is allowed to be expanded. The BeforeExpandEventArgs.CanExpand event’s parameter must be used for this purpose.

If your aim is to perform specific actions each time a node has been expanded, consider using the TreeList.AfterExpand event.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the BeforeExpand 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