* Find a root node in the TreeView oTree = .TList2 if oTree.Nodes.count > 0 for i = 1 to oTree.Nodes.count oTmp = oTree.Nodes(i).parent if isnull(oTmp) then iTmpIndex = i exit endif next iWhich finds only one of the possible multiple root nodes of the treeview, wouldn't be faster to do
select node_id from ItemTree where parent_id is null into cursor c_roots...You might even be able to avoid the next step, finding the sibling if you use order by sort_order, I think. Anyways, what I am trying to say is that maybe it is better to work with a mix of data instead of just scanning the tree which might be expensive.