Treeview: Drag'n drop and parent/children relation

L

L.M

Hello,

When doing a drag'n drop of a node in a treeview, is there an easy way to
make sure that the destination is not a children (at any level) of the
source ?

Root:
- A
- B
- C
- D

Like moving D on B is good, but moving B in D is not.
I discovered that moving A anywhere in the tree bellow it just make
everything disapeared.

I was thing to check that with the node.FullPath property, but was wondering
if there wasn't anything more easey or already implemented.

L.
 
S

solex

FullPath property sounds good it would be a simple check
From your example

sourcePath = "\A\B\C\D"
destinationPath = "\A\B"

If Instr(sourcePath, destinationPath) =1 Then
' Good
Else
' No can do
End If
 
L

L.M

That make it perfectly, Thanks.
Isn't VB provide a call to check if any node is part of the path ? I was
thinking so....
 
S

solex

LM,
There is no method I know of that would tell you this, except for
recursively iterating through a collection of nodes to determine if the node
you are trying to copy is a descendant of the parent. IMHO the method below
seams to be very simple and quick.
Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top