property CascadeTree.ExecuteContextMenu as Long
Executes a command from the object's context menu.

TypeDescription
Long A Long expression that determines the identifier of the command to be executed.
By default, the ExecuteContextMenu property is 0. The ExecuteContextMenu property specifies the identifier of the command to be executed ( id option in the ShowContextMenu property). The ExecuteContextMenu property has effect only during the ViewEndChanging event, when the Operation parameter is exExecuteContextMenu(21). The AllowContextMenu property specifies whether the control shows the object's context menu when the user presses the right click over a file or folder.

The following sample shows how you can append new items to the object's context menu and displays a message when a command is selected from the context menu:

Private Sub CascadeTree1_StateChange(ByVal State As EXCASCADETREELibCtl.StateChangeEnum)
    With CascadeTree1
        If (State = ShowContextMenu) Then
            .ShowContextMenu = .ShowContextMenu + ",Item 1[id=1][def],Popup[id=2](Sub-Item 2[id=2],[sep],Sub-Item 3[id=3])"
        Else
            If (State = ExecuteContextMenu) Then
                Debug.Print "You selected the command: " & .ExecuteContextMenu
            End If
        End If
    End With
End Sub

The following sample shows how you can prevent executing a specific command:

Private Sub CascadeTree1_StateChange(ByVal State As EXCASCADETREELibCtl.StateChangeEnum)
    With CascadeTree1
        If (State = ExecuteContextMenu) Then
            If Not (.ExecuteContextMenu = 17) Then   ' Delete
                Debug.Print "You selected the command: " & .ExecuteContextMenu
            Else
                .ExecuteContextMenu = 0
                MsgBox "Delete is disabled."
            End If
        End If
    End With
End Sub