campinas
asked on
Re-order Nodes in TreeView
In VB6, using the TreeView control:
I need to let the user re-order nodes under a parent node, manually, by drag and drop (question is not about drag and drop details).
When I drop the source node, I can add a copy to the target position and delete the source node. However, this gets complicated when the source node has children.
Unfortunately, the Previous and Next properties of a node are read-only.
QUESTION is,
What wuld be an elegant method of moving nodes around, under the same parent ?
I need to let the user re-order nodes under a parent node, manually, by drag and drop (question is not about drag and drop details).
When I drop the source node, I can add a copy to the target position and delete the source node. However, this gets complicated when the source node has children.
Unfortunately, the Previous and Next properties of a node are read-only.
QUESTION is,
What wuld be an elegant method of moving nodes around, under the same parent ?
ASKER
In my case the parent is the same.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You should use the Previous /Next properties of a Node object. This make the entire operation similar to moving an object in a double linked list.
As easy as 123. :)
Regards,
TILL
As easy as 123. :)
Regards,
TILL
ASKER
TILL, Previous and Next properties are read-only.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Moving nodes by changing parent doesn't give control over position under the new parent... Rebuilding the node is however not apealing for large nodes... It would be nice to have this "move in branch" feature built into the TreeView control. Thank you both for your hints!
Set movingNode.Parent = TreeView.Nodes(newParentNo