如何防止运行时在treeview中的节点扩展 [英] how to prevent node expansion in treeview on runtime

查看:49
本文介绍了如何防止运行时在treeview中的节点扩展的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我采用了静态树状视图,并带有以下类型的父节点和叶节点.
父节点
1. 管理器 _(节点值= 2)____________ 子节点
---------------------------- 1:管理人员
---------------------------- 2:教学人员
2:原理(节点值= 4)
3:老师(节点值= 3)

每个父节点都有特定的节点值(我对其进行了硬编码).
这些树节点应根据特定的用户权限出现.
我希望折叠第一个父级,直到未选中为止(仅由管理员使用键码= 1选中)


i have taken static treeview with some parent and leaf nodes of following type.
Parent Nodes
1. Manager_(node value=2)____________ child Nodes
----------------------------1: Management Staff
----------------------------2: Teaching Staff
2: Principle(node value=4)
3: Teachers(node value=3)

every parent node have specific node value(which i hardcoded).
These tree nodes should be appear according to specific user-rights.
i want first parent to be collapsed until it was not selected(only selectd by manger with keycode=1)


string str = " connection Qyery";
        DataTable mdt = cCommon.FillDataTable(str);
        string keycode = Convert.ToString(mdt.Rows[0]["KeyCode"]);


        if (mdt.Rows.Count > 0)
        {

            //parent node scan
            foreach (TreeNode node in admintree.Nodes)
            {
                      // all parent nodes are disable by default
                       node.SelectAction = TreeNodeSelectAction.None;
//Manager node
           if (keycode == "1" && node.Value == "2")
                {
                    // at this node i have two static child nodes.

                    node.SelectAction = TreeNodeSelectAction.Select;

                   // when this condition is false this parent node will not be seclected
                  // but expands.so the child are visible while condition is false.  
                }
// Principle node
                if (keycode == "4" && node.Value == "4")
                {
                    node.SelectAction = TreeNodeSelectAction.Select;
                                    }
// Teacher node
                if (keycode == "3" && node.Value == "3")
                {

                    node.SelectAction = TreeNodeSelectAction.Select;
                  }


               // this line for disable other nodes
             //node.SelectAction = TreeNodeSelectAction.None;

            }

        }


//展开具有子节点的第一个节点的事件.


// event for expnding first node which have childs.

protected void admintree_TreeNodeExpanded(object sender, TreeNodeEventArgs e)
{
    if (e.Node.Selected)
    {
        e.Node.ExpandAll();

    }
    else
    {

        e.Node.CollapseAll();
    }
}


但它不起作用请帮我解决这个问题.


but it is not working please help me sort out this.

推荐答案

以下链接将为您提供帮助.
http://forums.asp.net/t/1442802.aspx/1 [ ^ ]
http://support.microsoft.com/kb/319441 [
The following links will help you.
http://forums.asp.net/t/1442802.aspx/1[^]
http://support.microsoft.com/kb/319441[^]


这篇关于如何防止运行时在treeview中的节点扩展的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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