![]() | Type | Description | ||
| Group as Group | A Group object where the user expands or collapse an item. | |||
| Item as HITEM | A long expression that indicates the handle of the item being expanded or collapsed. | |||
| Cancel as Variant | A boolean expression that indicates whether the control cancel expanding or collapsing the item. |
The following sample cancels expanding or collapsing items in the first group:
Private Sub ExplorerTree1_BeforeExpandItem(ByVal Group As EXPLORERTREELibCtl.IGroup, ByVal Item As EXPLORERTREELibCtl.HITEM, Cancel As Variant)
If (Group.Index = 0) Then
Cancel = True
End If
End Sub
If your application expands items programmatically and you need to disable expanding or collapsing items only when user tries to click the left button of each parent item you can use an internal counter like in the following sample:
Dim iExpanding As Long
iExpanding = 0
iExpanding = iExpanding + 1
....
do expanding/collapsing items
...
iExpanding = iExpanding - 1
Private Sub ExplorerTree1_BeforeExpandItem(ByVal Group As EXPLORERTREELibCtl.IGroup, ByVal Item As EXPLORERTREELibCtl.HITEM, Cancel As Variant)
If iExpanding = 0 Then
If (Group.Index = 0) Then
Cancel = True
End If
End If
End Sub