I am trying to open a form for edit in the treeview nodemouseclick event when the treeview node text is clicked.
But the event opens my edit form when the node is expaned or collapsed too.
I implemented below and works fine when debugging with breakpoints.
Without breakpoints it ignores the before and after expand collapse events and goes to treenodeclick anyway
Private Sub TreeView1_BeforeExpand(sender As Object, e As TreeViewCancelEventArgs) Handles TreeView1.BeforeExpand
ExpandOrCollapse = True
End Sub
Private Sub TreeView1_AfterExpand(sender As Object, e As TreeViewEventArgs) Handles TreeView1.AfterExpand
ExpandOrCollapse = False
End Sub
Private Sub TreeView1_BeforeCollapse(sender As Object, e As TreeViewCancelEventArgs) Handles TreeView1.BeforeCollapse
ExpandOrCollapse = True
End Sub
Private Sub TreeView1_AfterCollapse(sender As Object, e As TreeViewEventArgs) Handles TreeView1.AfterCollapse
ExpandOrCollapse = False
End Sub
Private Sub TreeView1_NodeMouseClick(sender As Object, e As TreeNodeMouseClickEventArgs) Handles TreeView1.NodeMouseClick
If ExpandOrCollapse Then Return
end sub
it is a windows application.
what is the sequence of events?
beforeexpand, afterexpand and then nodemouseclick?