Treeview saga continued

D

Dale Fye

I apparantly don't understand what a root is, because
whenever I reference the root property of my treeview, it
gives me a reference to node(1).

I still have not figured out how to start at a given node
(lets say on the nodechecked event) and identify all of
the checked nodes children.

If I know what the index is of a node, how can I move to
that node (expand its parents to make sure it is visible)
and highlight it?

Also when I refer to the Parent property of a node that is
one of the nodes that appears when all nodes are
collapsed, Access give me an error: #91 "Object variable
or with block not set". So how do I tell what level in
the tree the node is at?
 
N

Neil

Dale,

The tree view control 'node click' events pass the node bing clicked into it
as an argument. From there, you can use the .Children property of this node
to count how many children the node has. Once you know this, you can then
loop through the children by creating a temp child node, get or change
values e.t.c. and then goto the next child. .FirstSibling returns the first
child node and .Next returns the next node in line (use the .Next property
of the temp child node to get to the next child). Hope that made sense.
Unfortunatly, I dont have Access handy to give u an example and it's been a
while since I used this control.

Hope it gives you a starting point,

Neil.
 
L

Luis

I use this portion of code within a For ... Next,
where "i" is the index of the For, to find a string in the
tree and to select and highlight the node where the string
was first found.
Maybe this could help. There are more eficient ways to do
this but this is the solution i have manage.

For i= 1 to num_of parent_nodes
Set objTree.SelectedItem = objTree.Nodes(i)

Set parent_node =objTree.NodesobjTree.SelectedItem.Key)
n_childrens = parent_node.Children
Set parent_node = parent_node.Child
For j = 1 To n_childrens
actualvalue = parent_node.Text
idx = objTree.Nodes(j).Index
exist = InStr(1, actualvalue, strsearch,
vbTextCompare)
If exist > 0 Then
Set objTree.SelectedItem = parent_node
objTree.SelectedItem.Expanded = True
Exit For
End If
Set parent_node= parent_node.Next
next j
next i
 

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