如题.大大们帮忙.

解决方案 »

  1.   

    MS的控件还是JS自己写的??
    写个递归查找
    找到后调用TreeNode的展开方法
      

  2.   

    如果采用了数据绑定的方式的话,可以在TreeNodeDataBound事件中进行比较处理,将指定节点的父节点展开就可以了,如果是递归方式的话在递归过程中判断。
      

  3.   

    参考一下这段代码:    void tvCatalog_TreeNodeDataBound(object sender, TreeNodeEventArgs e)
        {
            // 获取DataItem
            CFoodCatalogGB catalog = e.Node.DataItem as CFoodCatalogGB;
            if (catalog != null)
            {
                // 设置绑定方式
                e.Node.Text = catalog.Name;
                e.Node.Value = catalog.ID.ToString();
            }
            // 比较节点值并做出判断
            if(catalog.Name=="The value you wanted")
            {
                //
                // 在这里添加希望对目标节点进行的操作。
                //
                e.Node.Parent.Expand();
            }
        }
      

  4.   


    private TreeNode GetTreeNode(TreeNode node)
    {
        if (node.Text == "test")
        {
            return node;
        }
        if (node.Nodes.Count > 0)
        {
            foreach (TreeNode temp in node.Nodes)
            {
                TreeNode t = GetTreeNode(temp);
                if (t != null)
                {
                    return t;
                }
            }
        }
        return null;
    }
    TreeNode t = GetTreeNode(tv.Nodes[0]);
    if (t != null)
    {
        t.Expand();
    }
      

  5.   

    to:lovefootball 有一些小问题,例如这段
    if (t != null) 

        t.Expand(); 
    }不能简单的写成t.expand();吧!t还有parent t.parent可能还有parent 好像又要用递归去展开了
      

  6.   

    if (t != null) 

        t.Expand(); 
        TreeNode parent = t.Parent;
        while (parent != null)
        {
            parent.Expand();        if (parent.Parent != null)
            {
                parent = parent.Parent;
            }
            else
            {
                break;
            }
        }
    }
      

  7.   

    3Q to:lovefootball,drummery 小弟受教了.