procedure TForm2.FormShow(Sender: TObject);
var
i:Integer;
leftx:integer;
widthperbyte:integer;
Heading:TQRLabel;
QRLabel:TQRLabel;
QRshape1:TQRshape;
QRshape2:TQRShape;
QRdbtext:Tqrdbtext;
begin
widthperbyte:=10;
heading:=TQRLabel.Create(self);
heading.Parent:=form2.TitleBand1;
heading.Caption:='动态表';
heading.Font.Size:=16;
heading.Font.Style:=[fsbold];
heading.Alignment:=tacenter;
heading.Width:=length(heading.Caption)*(widthperbyte+4);
Heading.Left:=(form2.QuickRep1.Width-Heading.width)div 2;
Heading.Height:=form2.TitleBand1.Height-1;
Heading.Top:=0;
Leftx:=(Form2.quickrep1.width-totalwidth*widthperbyte)div 2;
form2.QuickRep1.Font.Size:=12;
for i:=0 to form1.ADOQuery1.FieldCount-1 do begin
if (form1.ADOQuery1.Fields.Fields[i].fieldname<>'A0100') and (form1.ADOQuery1.Fields.Fields[i].fieldname<>'recidx') then begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select * from table1');
adoquery1.SQL.Add('Where fieldid='''+form1.ADOQuery1.Fields.Fields[i].fieldname+'''');
adoquery1.Open;
QRShape1:=TQRSHape.Create(self);
QRShape1.parent:=form2.ColumnHeaderBand1;
QRShape1.Left:=Leftx;
QRShape1.Width:=maxwidth*widthperbyte+4;
QRShape1.Height:=Form2.ColumnHeaderBand1.Height;
QRShape1.top:=0;
QRLabel:=TQRLabel.Create(self);
QRLabel.parent:=Form2.ColumnHeaderBand1;
QRLabel.Font.Style:=[fsbold];
QRLabel.Left:=Leftx+2;
QRLabel.width:=maxwidth*widthperbyte;
QRLabel.height:=Form2.ColumnHeaderBand1.Height-2;
QRLabel.top:=1;
QRLabel.caption:=ADOQuery1.FieldValues['descr'];
QRShape2:=TQRSHAPE.Create(self);
QRShape2.Parent:=Form2.DetailBand1;
QRShape2.Left:=Leftx;
QRShape2.Width:=maxwidth*widthperbyte+4;
QRShape2.Height:=form2.DetailBand1.Height;
QRShape2.top:=0; QRDBText:=TQRDBText.Create(self);
QRDBText.parent:=Form2.DetailBand1;
QRDBText.Left:=Leftx+2;
QRDBText.Width:=maxwidth*widthperbyte;
QRDBText.Height:=Form2.DetailBand1.Height-2;
QRDBText.Top:=1;
qrdbtext.AutoSize:=false;
qrdbtext.Alignment:=tacenter;
QRDBText.DataSet:=Form1.ADOQuery1;
QRDBText.DataField:=Form1.ADOQuery1.Fields.Fields[i].FieldName;
Leftx:=Leftx+maxwidth*widthperbyte+4;
end;
end;
Form1.ADOQuery1.Active:=true;
Form2.QuickRep1.Preview;
end;
为什么这个报表预览的时候,只显示了数据表里的一条记录,怎么没有列标题,怎么也没有数据表里的其他记录,请高手们帮帮忙!!!
var
i:Integer;
leftx:integer;
widthperbyte:integer;
Heading:TQRLabel;
QRLabel:TQRLabel;
QRshape1:TQRshape;
QRshape2:TQRShape;
QRdbtext:Tqrdbtext;
begin
widthperbyte:=10;
heading:=TQRLabel.Create(self);
heading.Parent:=form2.TitleBand1;
heading.Caption:='动态表';
heading.Font.Size:=16;
heading.Font.Style:=[fsbold];
heading.Alignment:=tacenter;
heading.Width:=length(heading.Caption)*(widthperbyte+4);
Heading.Left:=(form2.QuickRep1.Width-Heading.width)div 2;
Heading.Height:=form2.TitleBand1.Height-1;
Heading.Top:=0;
Leftx:=(Form2.quickrep1.width-totalwidth*widthperbyte)div 2;
form2.QuickRep1.Font.Size:=12;
for i:=0 to form1.ADOQuery1.FieldCount-1 do begin
if (form1.ADOQuery1.Fields.Fields[i].fieldname<>'A0100') and (form1.ADOQuery1.Fields.Fields[i].fieldname<>'recidx') then begin
adoquery1.Close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('select * from table1');
adoquery1.SQL.Add('Where fieldid='''+form1.ADOQuery1.Fields.Fields[i].fieldname+'''');
adoquery1.Open;
QRShape1:=TQRSHape.Create(self);
QRShape1.parent:=form2.ColumnHeaderBand1;
QRShape1.Left:=Leftx;
QRShape1.Width:=maxwidth*widthperbyte+4;
QRShape1.Height:=Form2.ColumnHeaderBand1.Height;
QRShape1.top:=0;
QRLabel:=TQRLabel.Create(self);
QRLabel.parent:=Form2.ColumnHeaderBand1;
QRLabel.Font.Style:=[fsbold];
QRLabel.Left:=Leftx+2;
QRLabel.width:=maxwidth*widthperbyte;
QRLabel.height:=Form2.ColumnHeaderBand1.Height-2;
QRLabel.top:=1;
QRLabel.caption:=ADOQuery1.FieldValues['descr'];
QRShape2:=TQRSHAPE.Create(self);
QRShape2.Parent:=Form2.DetailBand1;
QRShape2.Left:=Leftx;
QRShape2.Width:=maxwidth*widthperbyte+4;
QRShape2.Height:=form2.DetailBand1.Height;
QRShape2.top:=0; QRDBText:=TQRDBText.Create(self);
QRDBText.parent:=Form2.DetailBand1;
QRDBText.Left:=Leftx+2;
QRDBText.Width:=maxwidth*widthperbyte;
QRDBText.Height:=Form2.DetailBand1.Height-2;
QRDBText.Top:=1;
qrdbtext.AutoSize:=false;
qrdbtext.Alignment:=tacenter;
QRDBText.DataSet:=Form1.ADOQuery1;
QRDBText.DataField:=Form1.ADOQuery1.Fields.Fields[i].FieldName;
Leftx:=Leftx+maxwidth*widthperbyte+4;
end;
end;
Form1.ADOQuery1.Active:=true;
Form2.QuickRep1.Preview;
end;
为什么这个报表预览的时候,只显示了数据表里的一条记录,怎么没有列标题,怎么也没有数据表里的其他记录,请高手们帮帮忙!!!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货