Sorting treeview nodes

G

Guest

I've got a treeview that works great. I'm now attempting to add a sorting
(move up/down) functionality within the tree. When the nodes are loaded,
they are loaded in accordance with a Sort_Order field in the underlying
database.

I have added several command buttons (move up, move down) to my form, and
the code behind these buttons is working properly to renumber the sort_order
field in the dataset. When I refresh the text property of the nodes (it
starts with the sort_order field formatted as 2 digit text), the text changes
as appropriate, although the items stay in the same position they were in in
the tree (despite having the tree controls "Sorted" property set to true).

I have added code to remove these two nodes whose position is being changed,
but cannot figure out how to insert the new nodes back in the proper sequence.

Any body have any recommendations? Would selecting the key from the
previous sibling and then using the tvwNext relationship result in an insert?
 
G

Guest

Figured out how to do this, if anyone is interested.

using the nodes.Add method, you can specify a node and the relationship to
that node when you do the addition. So if you want to insert a node between
two other nodes, find out the key value of the previous node, then use the
tvwNext relationship to add the new node following that node.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top