Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to move a node in a treeview via code?

Status
Not open for further replies.

BobTheMad

Programmer
Jun 11, 1999
81
US
I am developing a program where sub-nodes in a Treeview control occasionally need to be re-assigned to a different 'Parant' node. This event is triggered by an event other than the 'DragDrop' event (that part I have down pat). I have a trap for this external event already set, but I need to know how to get the actual nodes to move.

Thanks in advance

Thought for the day: Beware of Gods who cannot laugh...
 

Give something like this a try...
[tt]
Private Sub Form_Load()
Dim N As Node

TV.Style = tvwTreelinesPlusMinusText

Set N = TV.Nodes.Add(, , "Root", "Root")
Set N = TV.Nodes.Add("Root", tvwChild, "Child1", "Child1")
Set N = TV.Nodes.Add("Child1", tvwChild, "Child2", "Child1 of Child1")
Set N = TV.Nodes.Add("Root", tvwChild, "Child3", "Child2")

End Sub

Private Sub Command1_Click()
Dim N As Node
Set N = TV.Nodes("Child2")
Set N.Parent = TV.Nodes.Item("Child3")

End Sub
[/tt]

Good Luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top