DevExpress treelist CheckBoxes 赋初值

      //加载已赋权限的Check真假选项
       private void GetRolesCheckStateMenu()
       {
           //string s = string.Empty;
           foreach (TreeListNode node in treeListMenu.Nodes)
           {
               if (node.Nodes.Count == 0)
               {
                   //s = s + node.GetValue("PID").ToString() + "','";
                   return;
               }
               if (node.Nodes.Count > 0)
               {
                   GetRolesCheckChildMenu(node);
               }
           }
       }
      private void GetRolesCheckChildMenu(TreeListNode parentNode)
       {
           if (parentNode.Nodes.Count > 0)
           {
               foreach (TreeListNode node in parentNode.Nodes)
               {
                   if (node.Nodes.Count == 0)
                   {
                       string s = node.GetValue("RoleID").ToString(); //流程ID
                       if (!String.IsNullOrEmpty(s))
                       {
                           node.Checked = true;
                       }

                   }
                   if (node.Nodes.Count > 0)
                   {
                       GetRolesCheckChildMenu(node);
                   }
               }
           }
           if (parentNode.Nodes.Count == 0)
           {
               return;
           }
       }

 2、如非多级

     //1 加载已赋数据权限的Check真假选项
       private void GetFlowCheckStateMenu()
       {
           //string s = string.Empty;
           foreach (TreeListNode node in treeListFlowList.Nodes)
           {
               if (node.Nodes.Count == 0)
               {
                   string s = node.GetValue("FlowID").ToString(); //流程ID
                   if (!String.IsNullOrEmpty(s))
                   {
                       node.Checked = true;
                   }
                   //return;
               }
               if (node.Nodes.Count > 0)
               {
                   GetFlowCheckChildMenu(node);
               }
           }
       }
//2、子加载
      private void GetFlowCheckChildMenu(TreeListNode parentNode)
       {
           if (parentNode.Nodes.Count > 0)
           {
               foreach (TreeListNode node in parentNode.Nodes)
               {
                   if (node.Nodes.Count == 0)
                   {
                       string s = node.GetValue("FlowID").ToString(); //流程ID
                       if (!String.IsNullOrEmpty(s))
                       {
                           node.Checked = true;
                       }

                   }
                   if (node.Nodes.Count > 0)
                   {
                       GetFlowCheckChildMenu(node);
                   }
               }
           }
           if (parentNode.Nodes.Count == 0)
           {
               return;
           }
       }

 

posted @ 2016-08-14 16:58  一枚水  阅读(289)  评论(0)    收藏  举报