Expand Event (TreeView Control)

           

Occurs when a Node object in a TreeView control is expanded, that is, when its child nodes become visible.

Syntax

Private Sub object_Expand(ByVal node As Node)

The Expand 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 expanded Node object.

Remarks

The Expand event occurs after the Click and DblClick events.

The Expand event is generated in three ways: when the user double-clicks a Node object that has child nodes; when the Expanded property for a Node object is set to True; and when the plus/minus image is clicked. Use the Expand event to validate an object, as in the following example:

Private Sub TreeView1_Expand(ByVal Node As Node)
   If Node.Index <> 1 Then
      Node.Expanded = False   ' Prevent expand.
   End If
End Sub