ITPub博客

首页 > Linux操作系统 > Linux操作系统 > treeview控件的遍历【转】

treeview控件的遍历【转】

原创 Linux操作系统 作者:qhguan1984 时间:2008-01-09 11:37:35 0 删除 编辑

 public void BeginRoundTree(TreeView tree)
        {
            int TreeChildNum = tree.Nodes.Count;
            int i;
            for (i = 0; i < TreeChildNum; i++)
            {
                NodeAction(tree.Nodes[i]);
                RoundTree(tree.Nodes[i]);
            }
        }
       
        //便历树  
        public void RoundTree(TreeNode treenode)
        {
            int childnum = treenode.ChildNodes.Count;
            int i, j;
            for (i = 0; i < childnum; i++)
            {

                if (treenode.ChildNodes[i].ChildNodes.Count > 0)
                {
                    NodeAction(treenode.ChildNodes[i]);
                    RoundTree(treenode.ChildNodes[i]);

                }
                else
                {
                    NodeAction(treenode.ChildNodes[i]);
                }

            }
        }

        //判断是否被选中  
        public void NodeAction(TreeNode node)
        {
            if (node.Checked == true)
            {
                _teststr =_teststr + node.Value.ToString() + ",";
            }
        }

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/9900188/viewspace-120044/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2008-01-05

  • 博文量
    7
  • 访问量
    9555