你可以在使用QUICKREP中在程序外面动态的设置数据源和数据字段。然后在程序中动态的设置表和字段名称。

解决方案 »

  1.   

    动态设置QUICKREP中附件的属性行不行,试试!
      

  2.   

    在FORM上加入QuickRep,Table,设置Table的以下属性:DatabaseName,Table和Active。设置QuickRep的以下属性:DataSet、Bands(主要是HasDetail为True),然后在Form中的QuickRep上的DetailBand中加入若干QRDBText,设置其DataSet和DataField属性。OK.鼠标右键点击QuickRep的边缘,选择Preview.
      

  3.   

    楼上的有没有搞错? 是选择打印字段啊   我今天按照my_yc(海)的方法简单的做了一下procedure Tfrm_cxtjscbb.myrepBeforePrint(Sender: TCustomQuickRep;
      var PrintReport: Boolean);
    var i:integer;
        lb_top,lb_width,lb_space:integer;
    begin
    lb_top:=STOP;  
    lb_width:=SWIDTH;
    lb_space:=SSPACE;//大写的是常量
    with frm_rytj do
      begin
         For i:=0 to GroupBox1.ControlCount-1 do
           begin
             if groupbox1.Controls[i] is Tcheckbox then
                begin
                   if (groupbox1.Controls[i] as Tcheckbox).Checked then
                       begin
                           with TQRlabel.Create(columnheaderband1) do
                                begin
                                   tag:=i;
                                   parent:=columnheaderband1;
                                   font:=columnheaderband1.font;
                                   name:='lb'+inttostr(tag);
                                   caption:=Tcheckbox(groupbox1.Controls[i]).Caption;
                                   autosize:=true;
                                   top:=lb_top;
                                   left:=lb_space;
                                end;
                           with TQRDBtext.Create(detailband1) do
                                begin
                                  tag:=i;
                                  parent:=detailband1;
                                  font:=detailband1.Font;
                                  name:='dt'+inttostr(tag);
                                  autosize:=true;
                                  autostretch:=true;
                                  top:=STOP;
                                  left:=lb_space+3;
                                  dataset:=adoquery1;
                                  datafield:=Tcheckbox(groupbox1.Controls[i]).Caption;
                                end;
                              lb_space:=lb_space+lb_width+SSPACE;    
                       end;
                end;        end;end;
      if frm_rytj.adoquery1.recordcount<>0 then
         printreport:=true
      else printreport:=false;end;   
    但是不理想,根据选择字段多少的不同,排列不整齐,各位高手,怎么解决~~?