荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: jek (俊), 信区: Program
标  题: delphi报表网格自适应
发信站: 荔园晨风BBS站 (Tue Dec 11 20:35:50 2001), 转信

制作报表时经常会需要画一些空的表格,但一般用QReport制作出来的报表
如果是空的话,那么剩余部分是空白的,本文利用QReport里的SummaryBand
在上面画上剩余空间的网格。
TQReport在frmSale表单里,从Form1里调用TQReport,在Form1的Button2的
Click事件里处理添加代码。

本文参考"Delphi编制的程序运行中动态制作报表"一文。

procedure TForm1.Button2Click(Sender: TObject);
var
  heng: array[1..100] of TQRShape;//横线
  shu:  array[1..30] of TQRShape; //竖线
  shuright:array[1..30] of integer;//竖线间隔
  ff,i,j,long,mycount: integer;
begin
  mycount:=datamodul.dsSale.DataSet.RecordCount;
  with frmsale do begin
    long:=qrpsale.height-titleband1.Height-columnheaderband1.Height-
    detailband1.Height*mycount-pagefooterband1.Height-85;
    summaryband1.Height:=long;//把summaryband充满剩下的整个空间
    long:=long div detailband1.Height;//计算剩下空间可以画多少条横线
  end;
  for i:=1 to long do begin//开始画横线
    with frmSale do begin
      heng[i]:=TQRShape.Create(frmSale);
      heng[i].Parent:=summaryband1;
      with heng[i] do begin
        width:=1047;
        height:=1;
        top:=i*detailband1.Height;
        left:=0;
      end;
    end;
  end;
  mycount:=datamodul.dsSale.DataSet.FieldCount;
  with frmsale do begin
    ff:=2;
    shuright[1]:=QRDBText1.Left+QRDBText1.Width-ff;//计算每个字段
    shuright[2]:=QRDBText2.Left+QRDBText2.Width-ff;//的Right值
    shuright[3]:=QRDBText3.Left+QRDBText3.Width-ff;
    shuright[4]:=QRDBText4.Left+QRDBText4.Width-ff;
    shuright[5]:=QRDBText5.Left+QRDBText5.Width-ff;
    shuright[6]:=QRDBText6.Left+QRDBText6.Width-ff;
    shuright[7]:=QRDBText7.Left+QRDBText7.Width-ff;
    shuright[8]:=QRDBText8.Left+QRDBText8.Width-ff;
    shuright[9]:=QRDBText9.Left+QRDBText9.Width-ff;
    shuright[10]:=QRDBText10.Left+QRDBText10.Width-ff;
    shuright[11]:=QRDBText11.Left+QRDBText11.Width-ff;
    for j:=1 to mycount-1 do begin                      //画竖线
      with frmsale do begin
        shu[j]:=TQRShape.Create(frmsale);
        shu[j].Parent:=summaryband1;
        with shu[j] do begin
          width:=1;
          height:=long*detailband1.Height;
          left:=shuright[j];
          top:=0;
        end;
      end;
    end;
  end;
  frmsale.qrpSale.Preview;
end;

--
 === I love Puss forever ===

※ 来源:·荔园晨风BBS站 bbs.szu.edu.cn·[FROM: 192.168.1.242]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店