Selected Node in Treeview

G

Guest

Im sure I have asked this before, but I cant find my post....

Is it possible to get the position of a selected node within its parent?

e.g. Parent has 10 nodes and the 6th one is selected. I want to display on
my form "Selected Node = 6/10".

Thanks,
Steve.
 
G

Guest

In Answer to my own question.

I have found the solution at
http://experts.about.com/q/Visual-Basic-1048/treeview-control-issue-1.htm

Here is my lovely new piece of code to tell me which node is currently
selected. Basically, it uses the Node.Next command and a couple of variables
to get the required values (Total and currently selected).

With Forms!zSYS_frmWorkflow

Set otv = .xTree.Object

Dim aNode As Node
Dim intNodeCount As Integer
Dim intCurNode As Integer

Set aNode = otv.SelectedItem.Parent.Child

Do Until aNode Is Nothing
intNodeCount = intNodeCount + 1
If aNode.Selected = True Then intCurNode = intNodeCount
Set aNode = aNode.Next
Loop

End With
 

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