zoukankan      html  css  js  c++  java
  • 把多个menu绑定到treeview

    private void  GetMenuCount(System.Web.UI.Control parentCountol)//找到memu的个数 
        {
            if (parentCountol.HasControls())
            {
                foreach (System.Web.UI.Control c in parentCountol.Controls)
                {
                    if (c is System.Web.UI.WebControls.Menu)
                    {
                        BindTreeView(((System.Web.UI.WebControls.Menu)c).Items, TreeView1.Nodes);
                    }
                   
                    GetMenuCount(c);
                }
            }
           
        }


        private void BindTreeView(MenuItemCollection menuItemCollection,TreeNodeCollection treeNodeCollection)//把menu绑定到treeview上
        {
            foreach (MenuItem menuItem in menuItemCollection)
            {
                TreeNode treeNode = new TreeNode();
                treeNode.Text = menuItem.Text;
                treeNode.ShowCheckBox = true;

                treeNodeCollection.Add(treeNode);

                if (menuItem.ChildItems.Count != 0)//递归
                {
                    BindTreeView(menuItem.ChildItems,treeNode.ChildNodes);
                   
                }
            }
        }

  • 相关阅读:
    hdu 1856 More is better
    hdu 1014 Uniform Generator
    hdu 1412 {A} + {B}
    hdu 1022 Train Problem I
    hdu 1027 Ignatius and the Princess II
    hdu 2377 Bus Pass
    POJ 1141 Brackets Sequence
    guava学习,集合专题
    org.apache.commons等常用工具学习
    utf-8mb4和排序规则
  • 原文地址:https://www.cnblogs.com/tongdengquan/p/6090626.html
Copyright © 2011-2022 走看看