如何取消选中树视图中的节点 [英] how to uncheck nodes in treeview

查看:453
本文介绍了如何取消选中树视图中的节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好.
如何在Treeview控件中取消选中子节点以及基于子子节点..

hi to all..
how to uncheck the childnodes and based on sub childnodes also in treeview control..
if any body knows pls let me know.

推荐答案

尝试以下代码.

Try out the below code.

protected void treeview_UncheckAll1(TreeView tv)
        {
            TreeNode myNode = tv.SelectedNode;
            myNode.Checked = true;
            TreeNode root = tv.Nodes[0];
            foreach (TreeNode level1 in root.ChildNodes)
            {
                foreach (TreeNode level2 in level1.ChildNodes)
                {
                    level2.ImageUrl = "";
                    level2.Checked = false;

                    foreach (TreeNode level3 in level2.ChildNodes)
                    {
                        level3.ImageUrl = "";
                        level3.Checked = false;
                    }
                }
            }
        }


内部循环取决于您拥有的树视图的深度.
如果尚未检查,则需要检查myNode null编码.


The inner loop depends on the depth of the treeview you have.
You need to check for the myNode null codition if non been check.


这篇关于如何取消选中树视图中的节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆