PDA

Click to See Complete Forum and Search --> : TreeView Up


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

thinktank
Sep 11th, 2001, 01:15 PM
Plain logic :

1. Create a new node at the desired position.
2. Delete the old one.

Sajiv
Sep 11th, 2001, 11:42 PM
Thinktank.
Try Inserting a new node and then push the tree up.Your Plain Logic goes for a toss

abdul
Sep 11th, 2001, 11:43 PM
It should be in some kind of vb forum:p