'在Parent上增加一个子Node,内容来自SrcNode
Private Function AddNode(SrcNode As Node, Parent As Node) As Node
'自己写
End Function'把SubNode移动到Parent下
Sub MoveNode(SubNode As Node, Parent As Node)
Dim x As Node
Set x = AddNode(SubNode, Parent)
Dim c As Node
Set c = SubNode.Child
While Not c Is Nothing
MoveNode c, x
Set c = c.Next
Wend
yourtreeview.Nodes.Remove SubNode.Index
End Sub上面的方法有个限制:节点的Key属性必需是空的,否则会有冲突。
Private Function AddNode(SrcNode As Node, Parent As Node) As Node
'自己写
End Function'把SubNode移动到Parent下
Sub MoveNode(SubNode As Node, Parent As Node)
Dim x As Node
Set x = AddNode(SubNode, Parent)
Dim c As Node
Set c = SubNode.Child
While Not c Is Nothing
MoveNode c, x
Set c = c.Next
Wend
yourtreeview.Nodes.Remove SubNode.Index
End Sub上面的方法有个限制:节点的Key属性必需是空的,否则会有冲突。
Set T.Nodes(A).Parent=T.Nodes(B)
T为Treeview
----- 我要一百分 ---------
我使用的Treeview是跟着数据库的,所以Parent和Key两个属性都不能为空,如过属性为空
的话,就好办的多了,之所以请叫各位就是如何使用算法在移动节点时,自动的更改相应节点的
Parent,key值,我该如何解决Parent,key值的冲突!
急!!
忘了告诉你,我的email: [email protected]
'dtnode the destnode
Private Sub Movesubtree(ByVal sourcend As Node, ByVal dtnode As Node)
On Error GoTo el
Dim i As Long, so As Node, de As Node
If sourcend Is Nothing Or dtnode Is Nothing Then Exit Sub
If sourcend.Children = 0 Then Exit Sub
Set so = sourcend.Child
For i = 1 To sourcend.Children
Set de = Estree.Nodes.Add(dtnode, tvwChild, , so.Text, "close")
de.Tag = so.Tag
Movesubtree so, de
Set so = so.Next
Next
Exit Sub
el: If Err.Number <> 0 Then MsgBox Err.Description & "in Movesubtree!"
Exit Sub
End Sub