您的位置:首页 > 其它

实现 cxTreeList使用复选框实现多选 自动级联选择

2013-10-18 16:55 323 查看
var
  RootNode,SonNode:TcxTreeListNode;
  qryRoot,qrySon:TADOQuery;     
  
  cxTreeList1.OptionsView.CheckGroups:=true;
  cxTreeList1.Root.CheckGroupType:=ncgCheckGroup;  
  qryRoot:=TAdoQuery.create(nil);  
  qrySon:=TAdoQuery.create(nil);  
  qryRoot.Connection:=con1; 
 qrySon.Connection:=con1;  
 try     
 with qryRoot do   
 begin      
	 Close;		  
	 SQL.Text:='SELECT DISTINCT  PID,Caption FROM dbo.Parent';
	 Open;
      qrySon.Close;
      qrySon.SQL.Text:='SELECT PID,SID,Caption FROM dbo.Son  ORDER BY PID,SID';
      qrySon.Open;
      cxTreeList1.Clear;
      DisableControls;
      while not eof do     
 	  begin        
	    RootNode:=cxTreeList1.Add;
        RootNode.CheckGroupType:=ncgCheckGroup;
        RootNode.Texts[0]:=FieldByName('PID').AsString+'.'+FieldByName('Caption').AsString;
        RootNode.Texts[1]:=FieldByName('PID').AsString;
        RootNode.Enabled:=False;
        with qrySon do        begin          DisableControls;
          Filtered:=False;
          Filter:='PID='+QuotedStr(FieldByName('PID').AsString);
          Filtered:=True;
          while not Eof  do        
		  begin            
		    SonNode:=RootNode.AddChild;
            SonNode.Texts[0]:=trim(FieldByName('SID').AsString)+'.'+FieldByName('Caption').AsString;
            SonNode.Texts[1]:=trim(FieldByName('SID').AsString);
            Next;
          end;
          EnableControls;
        end;
        Next;
      end;
      EnableControls;
    end;
  finally    
    qryRoot.Free;
    qrySon.Free;
  end;


实现 cxTreeList使用复选框实现多选 自动级联选择
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐