
Get TreeView MouseUp event to recognize parent/child
This works ideally, except for one thing. If I only have
one parent and it has no children, it beleives that the
node is a child. It's not likely that my tree will ever
have just one parent and no children, but I want to cover
for that.
Quote:
>-----Original Message-----
>Private Sub TreeView1_MouseUp(Button As Integer, _
> Shift As Integer, x As Single, y As Single)
>Dim oNode As MSComctlLib.Node
> If Button = vbRightButton Then
> Set oNode = TreeView1.HitTest(x, y)
> If Not oNode Is Nothing Then
> 'Mouse is on a node (oNode)
> 'If you want this to become the active node...
> Set TreeView1.SelectedItem = oNode
> 'Test for parent node
> If oNode.Children > 0 Then
> 'Node has children (parent node)
> Else
> 'Node has no children (leaf node)
> End If
> Else
> 'Mouse is not on any node
> End If
> End If
>End Sub
>HTH,
>Rocky Clark (Kath-Rock Software)
>> Hi All:
>> I have a treeview control that allows a popup menu to
>> appear by using the MouseUp event of TreeView control.
>> However, how do I test whether the user has right-
clicked
>> on a parent node, a child node, or just white space?
>> tod
>.