Generated when any Node object in a TreeView control is collapsed.
Syntax
Private Sub object_Collapse(ByVal node As Node)
The Collapse event syntax has these parts:
Part | Description |
object | An object expression that evaluates to an object in the Applies To list. |
node | A reference to the clicked Node object. |
Remarks
The Collapse event occurs before the standard Click event.
There are three methods of collapsing a Node: by setting the Node object's Expanded property to False, by double-clicking a Node object, and by clicking a plus/minus image when the TreeView control's Style property is set to a style that includes plus/minus images. All of these methods generate the Collapse event.
The event passes a reference to the collapsed Node object. The reference can validate an action, as in the following example:
Private Sub TreeView1_Collapse(ByVal Node As Node)
If Node.Index = 1 Then
Node.Expanded = True ' Expand the node again.
End If
End Sub