windowsforms-devexpress-dot-xtratreelist-dot-treelist-64f982fb.md
Fires immediately after a node has been expanded.
Namespace : DevExpress.XtraTreeList
Assembly : DevExpress.XtraTreeList.v25.2.dll
NuGet Packages : DevExpress.Win.Navigation, DevExpress.Win.TreeList
public event NodeEventHandler AfterExpand
Public Event AfterExpand As NodeEventHandler
The AfterExpand event's data class is NodeEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| Node | Gets the current Tree List node. |
Each node within the Tree List control can have a number of child nodes. Child nodes can be hidden and made visible by collapsing or expanding their parent nodes respectively. Nodes can be expanded and collapsed in the following ways:
In all cases, the AfterExpand event fires immediately after expanding the node.
The following sample code changes state images of parent nodes when they are expanded or collapsed. The TreeList.AfterExpand and TreeList.AfterCollapse events are handled for this purpose.
private void treeList1_AfterCollapse(object sender, DevExpress.XtraTreeList.NodeEventArgs e) {
e.Node.StateImageIndex = 0;
}
private void treeList1_AfterExpand(object sender, DevExpress.XtraTreeList.NodeEventArgs e) {
e.Node.StateImageIndex = 1;
}
Imports DevExpress.XtraTreeList
Private Sub TreeList1_AfterCollapse(ByVal sender As Object, _
ByVal e As NodeEventArgs) Handles TreeList1.AfterCollapse
e.Node.StateImageIndex = 0
End Sub
Private Sub TreeList1_AfterExpand(ByVal sender As Object, _
ByVal e As NodeEventArgs) Handles TreeList1.AfterExpand
e.Node.StateImageIndex = 1
End Sub
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the AfterExpand 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.
winforms-treelist-create-file-manager-drag-drop-files-folders/CS/FileList/FileListHelper.cs#L29
Tree.BeforeExpand += new DevExpress.XtraTreeList.BeforeExpandEventHandler(this.treeList1_BeforeExpand);
Tree.AfterExpand += new DevExpress.XtraTreeList.NodeEventHandler(this.treeList1_AfterExpand);
Tree.AfterCollapse += new DevExpress.XtraTreeList.NodeEventHandler(this.treeList1_AfterCollapse);
winforms-treelist-create-file-manager-drag-drop-files-folders/VB/FileList/FileListHelper.vb#L31
AddHandler Me.Tree.BeforeExpand, New BeforeExpandEventHandler(AddressOf treeList1_BeforeExpand)
AddHandler Me.Tree.AfterExpand, New NodeEventHandler(AddressOf treeList1_AfterExpand)
AddHandler Me.Tree.AfterCollapse, New NodeEventHandler(AddressOf treeList1_AfterCollapse)
See Also