TreeNode and Parent Object

GregSmith

Registered User.
Local time
Today, 14:54
Joined
Feb 22, 2002
Messages
126
When I click on the parent node plus sign and it expands and shows the child nodes, how can I get it to msgbox me when I click on the child node what the orginal parent node was?
 
GregSmith said:
When I click on the parent node plus sign and it expands and shows the child nodes, how can I get it to msgbox me when I click on the child node what the orginal parent node was?

I am not sure that I fully understood the problem, but will give it a try.
The code below puts the key of the expanded node into a control.
When you cliks on the tree it checks if you clicked on a node and if the key of the clicked node is the same than the one we stored during expand pops up a message box.

hth
SWK


'Remember the key of the expanded node
Private Sub xtree_Expand(ByVal PNode As Object)
PNode.Key=Me.ExpandedNode
End Sub

'Test for new cliks on the tree
Private Sub xtree_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Long, ByVal Y As Long)
Dim CurrNode As Node
Dim oTree As TreeView

Set oTree = Me.xtree.Object
Set oTree.DropHighlight = oTree.HitTest(X, Y)
Set CurrNode = oTree.HitTest(X, Y)

If CurrNode Is Nothing Then
Exit Sub
End If

If CurrNode.Parent.Key=Me.ExpandedNode Then
msgbox "Last expanded node is the parent node of the current node!"
End if

End Sub
 

Users who are viewing this thread

Back
Top Bottom