Sajiv
Sep 11th, 2001, 08:28 AM
Hi
I had posted a help asking how to Move an Node in a Tree Up and down.It is really unfortunate that none of them came up with the code.
Here is the code which does the Following.
On a treeview control it rearranges the node when the button move up is pressed.
Private Sub mnuMU_Click()
Dim sFirstSib As String, sClickedText As String, sPrevText As String
Dim sParentKey As String,sCurKey as string,sPrevkey as string
Dim iPAFno As Integer, iCAFno As Integer
'STORE THE FIRST SIBLING OF THE CURRENTLY CLICKED ROOT NODE
sFirstSib = treSummary.Nodes(sKey).FirstSibling
'IF THE TEXT OF THE CLICKED NODE IS EQUAL TO THE FIRSTSIBLING THEN U CANNOT MOVE THE ITEM UP.
If (treSummary.Nodes(sKey).Text) = sFirstSib Then
MsgBox "Cannot Move Up", vbInformation, Title
Else
sPrevKey = treSummary.Nodes(frmInsertTree.sKey).Previous.Key
sCurKey = treSummary.Nodes(sKey).Key
sParentKey = treSummary.Nodes(sKey).Parent.Key
sClickedText = treSummary.Nodes(sKey).Text
sPrevText = treSummary.Nodes(sKey).Previous
treSummary.Nodes(sPrevKey).Text = sClickedText
treSummary.Nodes(sCurKey).Text = sPrevText
End If
End Sub
Private Sub treSummary_NodeClick(ByVal Node As MSComctlLib.Node)
skey=node.key
End sub
I had posted a help asking how to Move an Node in a Tree Up and down.It is really unfortunate that none of them came up with the code.
Here is the code which does the Following.
On a treeview control it rearranges the node when the button move up is pressed.
Private Sub mnuMU_Click()
Dim sFirstSib As String, sClickedText As String, sPrevText As String
Dim sParentKey As String,sCurKey as string,sPrevkey as string
Dim iPAFno As Integer, iCAFno As Integer
'STORE THE FIRST SIBLING OF THE CURRENTLY CLICKED ROOT NODE
sFirstSib = treSummary.Nodes(sKey).FirstSibling
'IF THE TEXT OF THE CLICKED NODE IS EQUAL TO THE FIRSTSIBLING THEN U CANNOT MOVE THE ITEM UP.
If (treSummary.Nodes(sKey).Text) = sFirstSib Then
MsgBox "Cannot Move Up", vbInformation, Title
Else
sPrevKey = treSummary.Nodes(frmInsertTree.sKey).Previous.Key
sCurKey = treSummary.Nodes(sKey).Key
sParentKey = treSummary.Nodes(sKey).Parent.Key
sClickedText = treSummary.Nodes(sKey).Text
sPrevText = treSummary.Nodes(sKey).Previous
treSummary.Nodes(sPrevKey).Text = sClickedText
treSummary.Nodes(sCurKey).Text = sPrevText
End If
End Sub
Private Sub treSummary_NodeClick(ByVal Node As MSComctlLib.Node)
skey=node.key
End sub