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!

Moving icons in treeview

Status
Not open for further replies.

Muddmuse

Programmer
Jul 31, 2001
85
US
I have buttons on a form that allow the selected node of a treeview to be repositioned up or down. Everything works fine except the image property. The images do get swapped but clicking on either of the repositioned nodes changes the images back to the original settings even though the nodeclick event does not contain any code to reload the tree. Here is my code:

Set selNode = TreeView1.SelectedItem
strTempName = selNode.Text
strTempTag = selNode.Tag
strTempKey1 = selNode.Key
strTempImg = selNode.Image

'intIndex is the previous or next node in the tree
Set newNode = TreeView1.Nodes(intIndex)

'swap info between selnode and newnode
With selNode
.Text = newNode.Text
newNode.Text = strTempName
.Tag = newNode.Tag
newNode.Tag = strTempTag
.Image = newNode.Image
newNode.Image = strTempImg
.Key = "" ' set to nothing to avoid duplicates
strTempKey2 = newNode.Key ' store newnode key and swap
newNode.Key = strTempKey1
.Key = strTempKey2
End With

Set TreeView1.SelectedItem = newNode
TreeView1.SetFocus

Any ideas how to keep the swapped images from returning to their original values?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top