TreeViewExtensions.IndexFromNode Method
Gets a screen index from a given node and a given index above the node.
IndexFromNode(
node
as TreeViewNode,
startIndex
as Integer)
as Integer
Parameters
- node
- The node to find the index for.
- startIndex
- A index to use as a starting point in the search. If you know the index of a parent node or any node that is known to be above the node then using this parameter can speed up the search.
Returns
- Integer
- The index of the node if found, -1 if it was not found. (Note that a node only has screen index if its within expanded scope)
Remarks
This function needs to loop the Nodes, using it should be avoided for performance reasons. But there are valid cases where using a function like this cannot be avoided.
Since this function extends the TreeView control then it can be called like:
myIndex = TreeView1.IndexFromNode(myNode,myParentNodeIndex)
(The TreeViewExtensions.rbo module has to be in your project).NoteThere is another simpler variation of this function which can be used if a index of a parent node is not known. This variation is faster but requires a hint of a node that is above this node.
See Also
TreeViewExtensions Module