当前位置: 首页>>代码示例>>C#>>正文


C# TreeNode.Collapse方法代码示例

本文整理汇总了C#中TreeNode.Collapse方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNode.Collapse方法的具体用法?C# TreeNode.Collapse怎么用?C# TreeNode.Collapse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TreeNode的用法示例。


在下文中一共展示了TreeNode.Collapse方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
		if (!Page.IsPostBack)
		{
			DataSet ds = GetProductsAndCategories();

			// Loop through the category records.
			foreach (DataRow row in ds.Tables["Categories"].Rows)
			{
				// Use the constructor that requires just text
				// and a non-displayed value.
				TreeNode nodeCategory = new TreeNode(
					row["CategoryName"].ToString(),
					row["CategoryID"].ToString());

				TreeView1.Nodes.Add(nodeCategory);

				// Get the children (products) for this parent (category).
				DataRow[] childRows = row.GetChildRows(ds.Relations[0]);

				// Loop through all the products in this category.
				foreach (DataRow childRow in childRows)
				{
					TreeNode nodeProduct = new TreeNode(
						childRow["ProductName"].ToString(),
						childRow["ProductID"].ToString());
					nodeCategory.ChildNodes.Add(nodeProduct);
				}

				// Keep all categories collapsed (initially).
				nodeCategory.Collapse();
			}
		}
    }
开发者ID:Helen1987,项目名称:edu,代码行数:34,代码来源:TreeViewDB.aspx.cs

示例2: BuildChild

    /// <summary>
    /// 建立系統選單
    /// </summary>
    /// <param name="rootuid">傳入系統代號</param>
    /// <param name="nodes">傳入TreeView Node</param>
    private void BuildChild(string rootuid, 
                            TreeNodeCollection nodes
                            )
    {
        StringBuilder sb = new StringBuilder();

        TreeNode newnode = null;

        if (Session["UserProgramStatus"] != null)
        {
            DataRow[] rows = ((DataTable)Session["UserProgramStatus"]).Select(string.Format("ParentCODE = '{0}' and ISVISUAL = 1", rootuid));

            for (int i = 0; i < rows.Length; i++)
            {
                newnode = new TreeNode();

                newnode.Text = rows[i]["Name"].ToString();

                //如果是第一層就折疊
                if (rootuid == Request.QueryString["mid"].ToString().Trim())
                {
                    newnode.Collapse();
                }

                sb.Remove(0, sb.Length);
                sb.AppendFormat("javascript:SendMenuItemInfo('{0}','{1}');",
                                rows[i]["Name"].ToString(),
                                (rows[i]["LINKURL"].ToString().Trim() == "") ? "/WUI/FProgramDescList.aspx?Code=" + rows[i]["CODE"].ToString() : rows[i]["LINKURL"].ToString().Replace("~", "") + "?Code=" + rows[i]["CODE"].ToString()
                                );

                if (rows[i]["Status"].ToString() == "1")
                {
                    newnode.NavigateUrl = sb.ToString();
                    newnode.ToolTip = rows[i]["DESCRIPTION"].ToString();
                    newnode.Value = rows[i]["CODE"].ToString();
                }
                else
                {
                    newnode.Value = "no right";
                    newnode.ToolTip = "您尚無此功能權限!";
                }

                nodes.Add(newnode);
                BuildChild(rows[i]["CODE"].ToString(), newnode.ChildNodes);

            }
        }

    }
开发者ID:ChiangHanLung,项目名称:PIC_VDS,代码行数:54,代码来源:FMenu.aspx.cs

示例3: initMenu

    private void initMenu()
    {
        LoginUser user = sessionHelper.AdminUser;
        //快取載入
        UserMenuFuncContainer userContainer = UserMenuFuncContainer.GetInstance();

        if (user == null)
        {
            Response.Redirect(LOGIN_PAGE_MANAGER, false);
            return;
        }

        user = userContainer.GetUser(user.UserId);

        TreeveiwService tvService = new TreeveiwService();

        MenuFuncDao menuFuncDao = new MenuFuncDao();

        IList<MenuFunc> menuFuncList = authService.GetTopMenuFunc(user, userContainer.AllMenu, userContainer.RoleDic);

        foreach (MenuFunc menu in menuFuncList)
        {
            TreeNode treeNode = new TreeNode(menu.MenuFuncName, null, "", string.Format("javascript:__doPostBack('ctl00$tvMenu','t{0}')", menu.MenuFuncName), "");
            treeNode.Collapse();

            if (menu.SubFuncs.Count > 0)
            {
                foreach (MenuFunc subMenu in menu.SubFuncs)
                {
                    TreeNode subTreeNode = new TreeNode(subMenu.MenuFuncName, subMenu.MainPath);
                    //判斷使否選定
                    if (!string.IsNullOrEmpty(sessionHelper.FunctionName))
                    {
                        if (CollectionUtil.ContainValue(menu.SubFuncs, "MenuFuncName", sessionHelper.FunctionName))
                        {
                            treeNode.Expand();
                        }
                    }
                    treeNode.ChildNodes.Add(subTreeNode);
                }
            }
            tvMenu.Nodes.Add(treeNode);
        }

        //object c = userContainer.AllMenu;
        tvMenu.DataBind();
    }
开发者ID:dada2cindy,项目名称:wudada-eip,代码行数:47,代码来源:MasterPage.master.cs

示例4: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
		if (!Page.IsPostBack)
		{
			DataTable dtCategories = GetCategories();

			// Loop through the category records.
			foreach (DataRow row in dtCategories.Rows)
			{
				TreeNode nodeCategory = new TreeNode(
					row["CategoryName"].ToString(),
					row["CategoryID"].ToString());

				// Use the populate-on-demand feature for this
				// node's children.
				nodeCategory.PopulateOnDemand = true;

				// Make sure the node is collapsed at first,
				// so it's no populated immediately.
				nodeCategory.Collapse();
				TreeView1.Nodes.Add(nodeCategory);
			}
		}
    }
开发者ID:Helen1987,项目名称:edu,代码行数:24,代码来源:TreeViewDbOnDemand.aspx.cs

示例5: InsertNode

 /* value should be empty for classname nodes, namespace name for namespace nodes */
 private void InsertNode(TreeView tv, string text, string value, string valuepath, TreeNodeCollection parent)
 {
     TreeNode node = tv.FindNode(valuepath);
     if (node == null)
     {
         node = new TreeNode(Server.HtmlEncode(text), value);
         if (parent == null)
         {
             tv.Nodes.Add(node);
         }
         else
         {
             parent.Add(node);
         }
         if (valuepath == query_ns)
         {
             node.Selected = true;
         }
         else if (!query_ns.StartsWith(valuepath))
         {
             node.Collapse();
         }
     }
 }
开发者ID:mono,项目名称:moma-tool,代码行数:25,代码来源:NamespaceView.aspx.cs

示例6: CreateNode

    private TreeNode CreateNode(XmlNode xmlNode)
    {
        if (xmlNode.Attributes == null)
        {
            return null;
        }

        string module = xmlNode.Attributes["module"].InnerText;

        // Get node attributes
        string text = xmlNode.Attributes["text"].InnerText;
        string url = (xmlNode.Attributes["url"] != null) ? xmlNode.Attributes["url"].InnerText : null;
        string id = (xmlNode.Attributes["id"] != null) ? xmlNode.Attributes["id"].InnerText : null;

        if (string.IsNullOrEmpty(id))
        {
            id = module;
        }

        string onClickScript = "";

        // Create new node
        TreeNode node = new TreeNode();
        node.Collapse();

        if (!string.IsNullOrEmpty(url))
        {
            string urlStr = ScriptHelper.GetString(url);

            if (reqId.ToLowerCSafe() == id.ToLowerCSafe())
            {
                selectOnStartupScript = string.Format("var node = document.getElementById('node_{0}'); if(node != null){{ShowExample({1}, node);}}", id, urlStr);
            }

            node.SelectAction = TreeNodeSelectAction.None;

            // Prepare selection script
            onClickScript = string.Format("ShowExample({0}, this);", urlStr);
        }
        else
        {
            // Expand category node when clicked
            node.SelectAction = TreeNodeSelectAction.Expand;
        }

        // Create node text
        node.Text = String.Format("<span class=\"ContentTreeItem\" name=\"treeNode\" id=\"node_{2}\" onclick=\"{1}\"><span class=\"Name\">{0}</span></span>", text, onClickScript, id);

        return node;
    }
开发者ID:dlnuckolls,项目名称:pfh-paypalintegration,代码行数:50,代码来源:Menu.aspx.cs

示例7: UpdatePrograms

    void UpdatePrograms()
    {
        QueryResult programs;
        TreeNode CurrentNode, ParentNode, NotGroupedNode = null;
        string NodeValue;
        string[] collapsed = new string[1] { "" };
        if (Request.Cookies["TreeState"] != null)
          collapsed = Request.Cookies["TreeState"].Value.Split('|');

        UpdateVariables();
        ProgramsTree.Nodes.Clear();

        try
        {
          current.UpdateConnection();
          programs = Query.Execute(current.Connection, "select unique GetPathForProgram(p.programid) Path, p.programid, programcode, programname, description, runpath, parentprogramid, (select description from programs pp where pp.programid = p.parentprogramid) as parentdescription " +
                         "  from programs p, userprograms up " +
                         " where (up.userid = :1 or up.userid = :2) " +
                         "   and up.programid = p.programid " +
                         "   and runpath is not null " +
                         "   and visible = 1 " +
                         " order by GetSortForProgram(p.programid), programname ", new string[] { "1", "2" }, new object[] { current.User.id, current.User.groupid });
          for (int i = 0; i < programs.Rows.Count; i++)
          {
        NodeValue = String.Format("{0}|{1}|{2}|{3}",
                                  programs[i, "programid"].ToString(),
                                  programs[i, "programcode"].ToString(),
                                  programs[i, "runpath"].ToString(),
                                  current.User.id);
        CurrentNode = new TreeNode(programs[i, "programname"].ToString(), NodeValue);
        CurrentNode.ToolTip = programs[i, "description"].ToString();
        CurrentNode.SelectAction = TreeNodeSelectAction.Select;
        string[] nodes = programs[i, "path"].ToString().Split('|');
        if (nodes.Length == 1)
        {
          if (NotGroupedNode == null)
          {
            NotGroupedNode = new TreeNode("��� ������");
            NotGroupedNode.ToolTip = "� ��� �������� ������, �� �������������� �� � ����� ������� �������";
            NotGroupedNode.SelectAction = TreeNodeSelectAction.Expand;
            ProgramsTree.Nodes.Add(NotGroupedNode);
          }
          NotGroupedNode.ChildNodes.Add(CurrentNode);
        }
        else
        {
          ParentNode = FindParent(nodes[0]);
          if (ParentNode == null)
          {
            ParentNode = new TreeNode(nodes[0], programs[i, "parentprogramid"].ToString());
            ParentNode.ToolTip = programs[i, "parentdescription"].ToString();
            foreach (string s in collapsed)
              if (s == programs[i, "parentprogramid"].ToString())
                ParentNode.Collapse();
            ParentNode.SelectAction = TreeNodeSelectAction.Expand;
            ProgramsTree.Nodes.Add(ParentNode);
          }
          ParentNode.ChildNodes.Add(CurrentNode);
        }
          }
        }
        finally
        {
          current.CloseConnection();
        }
    }
开发者ID:PavelAlekseyuk,项目名称:OPSPortal,代码行数:66,代码来源:ProgramsList.aspx.cs

示例8: CreateNode

    private TreeNode CreateNode(XmlNode xmlNode)
    {
        string module = xmlNode.Attributes["module"].InnerText;
        string moduleName = "CMS." + module;
        bool loadModule = true;
        // Check if module is loaded
        if (ModuleEntry.IsModuleRegistered(moduleName) && !ModuleEntry.IsModuleLoaded(moduleName))
        {
            loadModule = false;
        }

        if (loadModule)
        {
            // Get node atributes
            string text = xmlNode.Attributes["text"].InnerText;
            string url = (xmlNode.Attributes["url"] != null) ? xmlNode.Attributes["url"].InnerText : null;
            string img = (xmlNode.Attributes["img"] != null) ? xmlNode.Attributes["img"].InnerText : null;
            string id = (xmlNode.Attributes["id"] != null) ? xmlNode.Attributes["id"].InnerText : null;

            // Get default icon
            if (string.IsNullOrEmpty(img))
            {
                img = string.Format("CMSModules/CMS_{0}/list.png", module.Replace(" ", ""));
            }

            string imgUrl = GetImageUrl(img);

            if (string.IsNullOrEmpty(id))
            {
                id = module;
            }

            string onClickScript = "";

            // Create new node
            TreeNode node = new TreeNode();
            node.Collapse();

            if (!string.IsNullOrEmpty(url))
            {
                string urlStr = ScriptHelper.GetString(url);

                if (reqId.ToLower() == id.ToLower())
                {
                    selectOnStartupScript = string.Format("var node = document.getElementById('node_{0}'); if(node != null){{ShowExample({1}, node);}}", id, urlStr);
                }

                node.SelectAction = TreeNodeSelectAction.None;

                // Prepare selection script
                onClickScript = string.Format("ShowExample({0}, this);", urlStr);
            }
            else
            {
                // Expand category node when clicked
                node.SelectAction = TreeNodeSelectAction.Expand;
            }

            // Create node text
            node.Text = String.Format("<span class=\"ContentTreeItem\" name=\"treeNode\" id=\"node_{3}\" onclick=\"{1}\"><img src=\"{2}\" class=\"TreeItemImage\" alt=\"{0}\" /><span class=\"Name\">{0}</span></span>", text, onClickScript, imgUrl, id);

            return node;
        }
        return null;
    }
开发者ID:KuduApps,项目名称:Kentico,代码行数:65,代码来源:Menu.aspx.cs

示例9: Populate_TreeView1

    protected void Populate_TreeView1()
    {
        // Populate TreeView

        //String CONNECTION = "Data Source=\\\\10.198.102.88\\c$\\ProgramData\\Admin Arsenal\\PDQ Inventory\\Database.db";
        String selectCommand = "select * from collections order by Name asc";
        //        String selectCommand = "select Name, IsOnline, Chassis from computers order by computerid desc";
        SQLiteDataAdapter dataAdapter =
                   new SQLiteDataAdapter(selectCommand, CONNECTION);
        TreeView1.Nodes.Clear();
        DataTable dt = new DataTable();
        dataAdapter.Fill(dt);
        foreach (DataRow node in dt.Rows)
        {
            if (node["ParentID"].ToString() == "")
            {
                TreeNode nodeParent = new TreeNode();
                nodeParent.Text = node["Name"].ToString();
                nodeParent.Value = node["CollectionId"].ToString();

                TreeView1.Nodes.Add(nodeParent);

                Populate_Nodes(dt, nodeParent);
                nodeParent.Value = "-" + node["CollectionId"].ToString();
                nodeParent.Collapse();
            }

        }
    }
开发者ID:kevindenham,项目名称:PDQ_Web,代码行数:29,代码来源:Default.aspx.cs

示例10: Populate_Nodes

 protected void Populate_Nodes(DataTable dt, TreeNode nodeParent)
 {
     foreach (DataRow cNode in dt.Rows)
     {
         if (cNode["ParentID"].ToString() == nodeParent.Value.ToString())
         {
             TreeNode nodeChild = new TreeNode();
             nodeChild.Text = cNode["Name"].ToString();
             nodeChild.Value = cNode["CollectionId"].ToString();
             nodeParent.ChildNodes.Add(nodeChild);
             Populate_Nodes(dt, nodeChild);
             nodeChild.Value = "-" + cNode["CollectionId"].ToString();
             nodeChild.Collapse();
         }
     }
 }
开发者ID:kevindenham,项目名称:PDQ_Web,代码行数:16,代码来源:Default.aspx.cs

示例11: GenareateSubMenu

    private void GenareateSubMenu(DataTable dtMenu, int RootMenuIndex, TreeNodeCollection TNC, int SuperID)
    {
        foreach (DataRow row in dtMenu.Select("SuperID=" + SuperID.ToString()))
        {
            int menuid = (int)row["ID"];
            TreeNode tn = new TreeNode();
            tn.Text = (string)row["Name"];
            if (dtMenu.Select("SuperID=" + menuid.ToString()).Length == 0)
            {
                tn.Value = RootMenuIndex.ToString() + "|" + menuid.ToString() + "|" + row["Remark"].ToString();
                tn.NavigateUrl = "~/SubModule/switch.aspx?Action=1&Module=" + menuid.ToString() + "&ActiveRootNode=" + RootMenuIndex.ToString();
                tn.Target = "fr_Main";
            }
            else
            {
                tn.Value = RootMenuIndex.ToString() + "|" + menuid.ToString();
                tn.SelectAction = TreeNodeSelectAction.Expand;
            }

            if (Session["ActiveModule"] != null && menuid == (int)Session["ActiveModule"])
            {
                tn.Select();
                //tn.Text = "<span style='color:red'>" + tn.Text + "</span>";
            }

            TNC.Add(tn);

            //if (dtMenu.Select("SuperID=" + menuid.ToString()).Length > 0 &&
            //    Session["ActiveRootNode"] != null && (int)Session["ActiveRootNode"] == RootMenuIndex)
            {
                //同主模块级下的树形先展开
                GenareateSubMenu(dtMenu, RootMenuIndex, tn.ChildNodes, menuid);
                tn.Collapse();
            }

            #region 获取当前已选择中节点的根节点,以便展开
            if (Session["ActiveModule"] != null && menuid == (int)Session["ActiveModule"])
            {
                TreeNode node = tn;
                while (node.Parent != null)
                {
                    node = node.Parent;
                }
                ViewState["CurrentRootNode"] = node.ValuePath;
            }
            #endregion
        }
    }
开发者ID:fuhongliang,项目名称:GraduateProject,代码行数:48,代码来源:LeftTreeMenu.aspx.cs

示例12: reloadSubTree

 private void reloadSubTree(TreeNode node, bool exp)
 {
     node.ChildNodes.Clear();
     int id = Convert.ToInt32(node.Value);
     DataTable dt = SalesmanCtrl.Salesman.getsByManager(id);
     foreach (DataRow row in dt.Rows)
     {
         TreeNode n = new TreeNode(row["userName"].ToString(), row["sysUserId"].ToString());
         node.ChildNodes.Add(n);
         reloadSubTree(n,false);
         if (exp)
             node.Expand();
         else
             node.Collapse();
     }
 }
开发者ID:rivernli,项目名称:SalesForecast,代码行数:16,代码来源:salesmanRelation.aspx.cs

示例13: CreateMIUCategories

 //建立重点怀疑对象单位结点
 void CreateMIUCategories(TreeNode node)
 {
     DataSet ds = DB.getMacIpUsers(User.Identity.Name);
     TreeNode newNode;
     int i = 0;
     string nodeText, nodeValue;
     if (ds.Tables.Count > 0)
     {
         foreach (DataRow row in ds.Tables[0].Rows)
         {
             nodeText = "<img src='images/isite3.gif' border=0 align='absmiddle'>" + row["vIp"].ToString() + "[" + row["vMac"].ToString() + "]<br> ∟[" + row["vMark"].ToString() + "]";
             nodeValue = row["nParent"].ToString() + "|" + row["vMac"].ToString() + "|" + row["vIp"].ToString() + "|" + row["nType"].ToString();
             newNode = new TreeNode(nodeText, nodeValue);
             //if (i == 0)
             //    newNode.Expand();
             //else
             newNode.Collapse();
             newNode.PopulateOnDemand = true;
             newNode.SelectAction = TreeNodeSelectAction.Expand;
             //newNode.ImageUrl = "~/src/images/isite3.gif";
             node.ChildNodes.Add(newNode);
             i = i + 1;
         }
     }
 }
开发者ID:tedi3231,项目名称:DMCProject,代码行数:26,代码来源:left.aspx.cs

示例14: CreateSiteCategories

 //建立控制中心单位结点
 void CreateSiteCategories(TreeNode node)
 {
     DataSet ds = DB.getSites(User.Identity.Name);
     TreeNode newNode;
     int i = 0;
     if (ds.Tables.Count > 0)
     {
         foreach (DataRow row in ds.Tables[0].Rows)
         {
             newNode = new TreeNode(row["VCorpName"].ToString(), row["nid"].ToString());
             //if (i == 0)
             //    newNode.Expand();
             //else
             newNode.Collapse();
             newNode.PopulateOnDemand = true;
             newNode.SelectAction = TreeNodeSelectAction.Expand;
             newNode.ImageUrl = "~/src/images/isite.gif";
             node.ChildNodes.Add(newNode);
             i = i + 1;
         }
     }
 }
开发者ID:tedi3231,项目名称:DMCProject,代码行数:23,代码来源:left.aspx.cs


注:本文中的TreeNode.Collapse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。