For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic Controls > January 2005 > Treeview looses children on drag'n'drop









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Treeview looses children on drag'n'drop
Johnny, Norway

2005-01-23, 9:00 pm

Hi

(Using vb6 sp5)

I have a treeview with drag'n'drop functionality. This works great, until I
try to drag'n'drop a node with children. The children disappears, even
though the node key is the same.

I think the problem may be caused because I remove the node from it's
original position before I add it, but how else can I retain the same key?
VB doesn't allow me to create two nodes with the same key. The remove/add
functionality is very simple:

TreeView1.Nodes.Remove (sKey)
TreeView1.Nodes.Add TreeView1.SelectedItem.Key, tvwChild, sKey, nodX.Text,
nodX.Image

(nodX is the node variable...)

If anyone have some thoughts, or even better, a solution, on this, I would
be very happy....

Regards, Johnny, Norway
Jörn Synnatzschke

2005-01-23, 9:01 pm

Hi Johnny,

i had the same problem and solved it by adding a new node at the drop
position with a temp key,
copying all properties of the drag node, moving all children to the temp
node, deleting the drag node,
and finally i gave to the new drop node the key of the drag node.

bye
Jörn

Johnny, Norway wrote:
> Hi
>
> (Using vb6 sp5)
>
> I have a treeview with drag'n'drop functionality. This works great,
> until I try to drag'n'drop a node with children. The children
> disappears, even though the node key is the same.
>
> I think the problem may be caused because I remove the node from it's
> original position before I add it, but how else can I retain the same
> key? VB doesn't allow me to create two nodes with the same key. The
> remove/add functionality is very simple:
>
> TreeView1.Nodes.Remove (sKey)
> TreeView1.Nodes.Add TreeView1.SelectedItem.Key, tvwChild, sKey,
> nodX.Text, nodX.Image
>
> (nodX is the node variable...)
>
> If anyone have some thoughts, or even better, a solution, on this, I
> would be very happy....
>
> Regards, Johnny, Norway



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com