how to search a TreeNode?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rob R. Ainscough

    #1

    how to search a TreeNode?

    Looking for an efficient way to get a TreeNode out of my rootTreeNode -- for
    example I know the FullPath -- is there a quick way to locate the node
    matching my FullPath?

    Rob.


  • blueskyenv@yahoo.com.cn

    #2
    Re: how to search a TreeNode?

    public TreeNode GetNodeByPath(T reeNode rootNode, string strFullPath)
    {
    if(rootNode==nu ll)
    return null;
    TreeNode hotNode = rootNode;
    string[] nodes = strFullPath.Spl it('\\');
    for(int i=1; i<nodes.Length ; i++)
    {
    TreeNode node0 = null;
    foreach(TreeNod e node in hotNode.Nodes)
    {
    if(node.Text == nodes[i])
    {
    node0 = node;
    break;
    }
    }
    if(node0 == null)
    break;
    hotNode = node0;
    }
    return hotNode;
    }

    Rob R. Ainscough wrote:[color=blue]
    > Looking for an efficient way to get a TreeNode out of my rootTreeNode -- for
    > example I know the FullPath -- is there a quick way to locate the node
    > matching my FullPath?
    >
    > Rob.[/color]

    Comment

    Working...