TreeView control questions

G

Guest

Hi! I have a couple issues with the TreeView control I'm wondering if any
of you would have an answer on.

Issue 1:
When I use the drag/drop feature, the child I drag gets placed at the top of
all the other existing children of the node I dropped it into. If I close
the form and get back in so it re-builds the tree, it's in the correct order
I want it in. Is there a way to automatically re-build the tree after I do a
drag/drop so it's in the correct order?

Issue 2:
Is there a way to color a node text on the fly as you build the tree? Also,
can you color a specific node on the tree based on a button you click on a
form?


Thanks so much for any ideas on these. I really appreciate it. I noticed
there's not a whole lot of documentation on the TreeView control.


Dan
 
W

William Hindman

1) clear the nodes and rebuild the tree from code
2) code I use to set a node color:

Set rst = CurrentDb.OpenRecordset(strSQL)
'Loop through recordset to add new tags
Do While Not (rst.EOF)
'Add New Node
Set ndNew = tvw.Nodes.Add(nd, tvwChild, , rst!ItemText,
rst!ImageIndex.Value)
'Set the node text color
ndNew.ForeColor = vbBlue
'Build Node Tag
ndNew.Tag = "Command=" & rst!Command & ";Argument=" & rst!Argument
'Check and see if we just added an Open Switchboard
If rst!Command = sbeOpenSwitchboard Then
'We did, so add children
sFillChildren ndNew
End If
'Move to next record
rst.MoveNext
Loop

....hth

William Hindman
 
G

Guest

Thanks a lot, William!

When I rebuild the tree from code it resets all the open/close positions of
the level 1 nodes. Is there any way to rebuild the tree while keeping the
open/close positions the same?


Thanks a lot for your help!


Ps. The color solution worked great.
 

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