
TreeView Drag n Drop don't allow dropping a parent into a child
You can check the Parent property of the node being dropped on. If it is the
same as the node being dragged, stop them.
Private Sub tv_OLEDragDrop(Index As Integer, Data As MSComctlLib.DataObject,
Effect As Long, Button As Integer, Shift As Integer, x As Single, Y As
Single)
Dim CurrentNode As Object
Set CurrentNode = tv.HitTest(x, Y) ' get the node being dropped to
If CurrentNode.parent.key = Node_Being_Dragged.key Then
' you have found a node being dragged onto one of it's children
Exit Sub
End If
Quote:
> I'm doing up this treeview control with drag'n drop. I need to stop the
> drop if a parent is being droped into one of it's children. Much like
> Explorer will stop you.
> In order to determine that the node being dropped is not a parent or the
> destination, do I have to loop through the nodes checking the keys and
such.
> Or (hopefully) there's a simplier method that has eluded me so far.
> Suggestions.
> Jeff