Back to Devexpress

TreeList.AfterExpand Event

windowsforms-devexpress-dot-xtratreelist-dot-treelist-64f982fb.md

latest5.5 KB
Original Source

TreeList.AfterExpand Event

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

Declaration

csharp
public event NodeEventHandler AfterExpand
vb
Public Event AfterExpand As NodeEventHandler

Event Data

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

PropertyDescription
NodeGets the current Tree List node.

Remarks

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.

Example

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.

csharp
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;
}
vb
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

csharp
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

vb
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

BeforeExpand

AfterCollapse

Expanded

TreeList.ExpandAll

ExpandToLevel(Int32)

TreeListNode.ExpandAll

TreeList Class

TreeList Members

DevExpress.XtraTreeList Namespace