I have a TreeView in VB6, when a Node's Image (+ or -) is clicked the Node expands then immediately collapses, or vice versa. I have a TreeView Click method which expands/collapses a Node when it is clicked (simplified version shown below)
Private Sub MyTreeView_Click()
Dim selectedNode As Node
Dim nodeType As String
Set selectedNode = MList2.SelectedItem
If selectedNode Is Nothing Then
Exit Sub
End If
nodeType = selectedNode.Key
If nodeType = "MyNodeType" Then
'Collapse Node if it's already expanded, otherwise expand it.
If selectedNode .Expanded Then
selectedNode .Expanded = False
Else
'Do some processing
selectedNode .Expanded = True
End If
End If
End Sub
This works fine if the text part of the Node is clicked. However if the Image part of the Node is clicked the Node is expanded/collapsed before this EventHandler is reached, resulting in the Node immediately returning to its original state when it does hit this EventHandler. The first expand/collapse of the Node seems to occur on MouseDown on the Node Image.
Does anyone know how I can prevent the Node from been expanded/collapsed before hitting this EventHandler when the Node Image is clicked?
Any help would be greatly appreciated, thanks in advance.