树的简单绑定

2015-04-05 22:15:51  访问(1887) 赞(0) 踩(0)


        /// <summary>
        /// 
        /// </summary>
        const string page_white = "page_white";

        /// <summary>
        /// 
        /// </summary>
        const string page_white_go = "page_white_go";

        /// <summary>
        /// 
        /// </summary>
        const string page = "page";

        /// <summary>
        /// 
        /// </summary>
        const string page_save = "page_save";


        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public ImageList CreateTreeIconImageList()
        {
            ImageList theResult = new ImageList();

            int idx = -1;

            theResult.Images.Add
                (
                    global::SlowX.StrOperApp.Properties.Resources.page_white
                );

            ++idx;
            theResult.Images.SetKeyName(idx, page_white);

            theResult.Images.Add
                (
                    global::SlowX.StrOperApp.Properties.Resources.page_white_go
                );

            ++idx;
            theResult.Images.SetKeyName(idx, page_white_go);

            theResult.Images.Add
                (
                    global::SlowX.StrOperApp.Properties.Resources.page
                );


            ++idx;
            theResult.Images.SetKeyName(idx, page);

            theResult.Images.Add
                (
                    global::SlowX.StrOperApp.Properties.Resources.page_save
                );


            ++idx;
            theResult.Images.SetKeyName(idx, page_save);

            return theResult;
        }
 
        /// <summary>
        /// n_
        /// </summary>
        protected const string n_ = "n_";
 
        /// <summary>
        /// 
        /// </summary>
        /// <param name="searchText"></param>
        protected void LoadTree(string searchText)
        {

            ImageList il = CreateTreeIconImageList();
            treeView_Main.ImageList = il;

            
            TreeNodeCollection tnc = treeView_Main.Nodes;

            TreeNode tn = null;
 
            SlowX.CreateGetSetApp.Enums.Oper.EmOper[]
                emOA = SlowX.CreateGetSetApp.Enums.Oper.EmArray;

            tnc.Clear();

            if (searchText == null || searchText.Length == 0)
            {


                foreach (SlowX.CreateGetSetApp.Enums.Oper.EmOper emO in emOA)
                {

                    tn = TreeNodeCreate(emO);
                    tnc.Add(tn);
                }
            }
            else
            {

                foreach (SlowX.CreateGetSetApp.Enums.Oper.EmOper emO in emOA)
                {

                    if (!emO.ToString().Contains(searchText))
                        continue;

                    tn = TreeNodeCreate(emO);
                    tnc.Add(tn);
                }
            }

            treeView_Main.ExpandAll();
        }

        /// <summary>
        /// 
        /// </summary> 
        /// <param name="em"></param>
        /// <returns></returns>
        public TreeNode TreeNodeCreate
            (
                SlowX.CreateGetSetApp.Enums.Oper.EmOper em
            )
        {
            TreeNode theResult = new TreeNode();
            theResult.Text = em.ToString();
            theResult.Tag = em;
            theResult.Name = n_   + ((int)em).ToString();

            theResult.ImageKey
               =
               page_white;

            theResult.SelectedImageKey
                =
                page_white_go;

            return theResult;
        }
         


标签:树的简单绑定 

上一条:

下一条:


 

相关评论

评论加载中……
 

发表评论

类型:
内容:
  (Alt+Enter)
 
  ┈全部┈  
 
(显示默认分类)