The event handler receives an argument of type BeforeCollapseEventArgs containing data related to this event.
The following
BeforeCollapseEventArgs properties provide information specific to this event.
Property |
Description |
CanCollapse |
Gets or sets a value indicating whether a Tree List node can collapse. |
Node |
Gets the current Tree List node. |
By default, the following actions result in collapsing a parent node:
Each time a node is about to be collapsed, the BeforeCollapse event fires. Write a handler for this event to specify whether the node is allowed to be collapsed. You must set the event's BeforeCollapseEventArgs.CanCollapse parameter to false to prohibit this action.
You can use the event for the following purposes:
- Prohibit the ability to collapse a specific node(s).
- Allow the ability to collapse nodes only when certain conditions are met.
If you want specific actions to be performed each time a node is collapsed, consider using the AfterCollapse event.

Example
The following sample code prohibits collapsing root-level nodes. The BeforeCollapse event is handled for this purpose.
C# |
using DevExpress.XtraTreeList;
private void treeList1_BeforeCollapse(object sender, BeforeCollapseEventArgs e) {
if (e.Node.Level == 0) e.CanCollapse = false;
}
|
VB |
Imports DevExpress.XtraTreeList
Private Sub TreeList1_BeforeCollapse(ByVal sender As Object, _
ByVal e As BeforeCollapseEventArgs) Handles TreeList1.BeforeCollapse
If e.Node.Level = 0 Then e.CanCollapse = False
End Sub
|