Move Treeview Child Node To Different Parent 
Author Message
 Move Treeview Child Node To Different Parent

How can I move a Child Node to a different parent and force the parent of
the parent to refresh so that the original parent of the child is deleted if
it is the only child node for the parent, and a new parent for the child is
created and the child is selected under the new parent.

Example:

    Agent
        Steve
            Child 1

change property on Child 1 record to be Dave instead of Steve.  Now want

    Agent
        Dave
            Child 1

Other scenario would be

    Agent
        STeve
            Child 1
            Child 2
        Dave
            Child 1

Moving Child 2 to Dave would result in

    Agent
        Steve
            Child 1
        Dave
            Child 1
            Child 2

Any coding examples showing order of steps would be appreciated.

Thanks
Steve



Fri, 24 Dec 2004 06:45:10 GMT  
 Move Treeview Child Node To Different Parent
You simply set the Node's Parent property.

If Node1 refers to your Child 1 node, and Node2 refers to Dave then your
code might look something like this --

Set OldParent = Node1.Parent
Set Node1.Parent = Node2
If OldParent.Children = 0 then
      MyTree.Nodes.Remove OldParent
end if


Quote:
> How can I move a Child Node to a different parent and force the parent of
> the parent to refresh so that the original parent of the child is deleted
if
> it is the only child node for the parent, and a new parent for the child
is
> created and the child is selected under the new parent.

> Example:

>     Agent
>         Steve
>             Child 1

> change property on Child 1 record to be Dave instead of Steve.  Now want

>     Agent
>         Dave
>             Child 1

> Other scenario would be

>     Agent
>         STeve
>             Child 1
>             Child 2
>         Dave
>             Child 1

> Moving Child 2 to Dave would result in

>     Agent
>         Steve
>             Child 1
>         Dave
>             Child 1
>             Child 2

> Any coding examples showing order of steps would be appreciated.

> Thanks
> Steve



Fri, 24 Dec 2004 07:30:48 GMT  
 Move Treeview Child Node To Different Parent
Thanks - that worked great.  One more question - how do I select force the
sorting of the parent children and then force the selection of the newly
modified child.
Steve


Quote:
> You simply set the Node's Parent property.

> If Node1 refers to your Child 1 node, and Node2 refers to Dave then your
> code might look something like this --

> Set OldParent = Node1.Parent
> Set Node1.Parent = Node2
> If OldParent.Children = 0 then
>       MyTree.Nodes.Remove OldParent
> end if



> > How can I move a Child Node to a different parent and force the parent
of
> > the parent to refresh so that the original parent of the child is
deleted
> if
> > it is the only child node for the parent, and a new parent for the child
> is
> > created and the child is selected under the new parent.

> > Example:

> >     Agent
> >         Steve
> >             Child 1

> > change property on Child 1 record to be Dave instead of Steve.  Now want

> >     Agent
> >         Dave
> >             Child 1

> > Other scenario would be

> >     Agent
> >         STeve
> >             Child 1
> >             Child 2
> >         Dave
> >             Child 1

> > Moving Child 2 to Dave would result in

> >     Agent
> >         Steve
> >             Child 1
> >         Dave
> >             Child 1
> >             Child 2

> > Any coding examples showing order of steps would be appreciated.

> > Thanks
> > Steve



Fri, 24 Dec 2004 13:07:43 GMT  
 Move Treeview Child Node To Different Parent
The TreeView's Sorted property should ensure that sibling nodes at any level
are sorted.


Quote:
> Thanks - that worked great.  One more question - how do I select force the
> sorting of the parent children and then force the selection of the newly
> modified child.
> Steve



> > You simply set the Node's Parent property.

> > If Node1 refers to your Child 1 node, and Node2 refers to Dave then your
> > code might look something like this --

> > Set OldParent = Node1.Parent
> > Set Node1.Parent = Node2
> > If OldParent.Children = 0 then
> >       MyTree.Nodes.Remove OldParent
> > end if



> > > How can I move a Child Node to a different parent and force the parent
> of
> > > the parent to refresh so that the original parent of the child is
> deleted
> > if
> > > it is the only child node for the parent, and a new parent for the
child
> > is
> > > created and the child is selected under the new parent.

> > > Example:

> > >     Agent
> > >         Steve
> > >             Child 1

> > > change property on Child 1 record to be Dave instead of Steve.  Now
want

> > >     Agent
> > >         Dave
> > >             Child 1

> > > Other scenario would be

> > >     Agent
> > >         STeve
> > >             Child 1
> > >             Child 2
> > >         Dave
> > >             Child 1

> > > Moving Child 2 to Dave would result in

> > >     Agent
> > >         Steve
> > >             Child 1
> > >         Dave
> > >             Child 1
> > >             Child 2

> > > Any coding examples showing order of steps would be appreciated.

> > > Thanks
> > > Steve



Fri, 24 Dec 2004 13:33:05 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. ReOrdering Child nodes Within Parent in treeview

2. Moving Parent Treeview Nodes

3. Moving nodes in Treeview with children

4. Moving nodes in Treeview with children

5. Moving Treeview Node to same level but different position

6. Move activex dll child on a MDI parent parent window

7. treeview - Move node, insert node

8. TreeView-Move Node Between Other Nodes?

9. Setting different tooltips for different TreeView nodes

10. TreeView: How insert a new node as a parent to an existing subtree

11. treeview - changing a nodes parent

12. treeview v6 parent node?

 

 
Powered by phpBB® Forum Software