我想做一动态报表,可是当我preview时只能看到QBand1中的内容,而且只有一行.可各位帮忙看一下问题在哪?procedure Tfrm_Find.BitBtn7Click(Sender: TObject);
var
MyLabel: TQRLabel;
MyText:TQRDBText;
FieldCount,i,LeftValue:integer;begin
Fieldcount:=frm_find.ADOQuery1.FieldCount;
leftValue:=0;
frm_find_Report.QuickRep1.DataSet:=frm_find.ADOQuery1;
for i:=0 to Fieldcount-1 do
begin
MyLabel:=TQRLabel.Create(frm_find_Report);
with frm_Find_Report do
MyLabel.Parent:=QRBand1;// HeaderBand1; //放在HeaderBand(rbDetail)里
with MyLabel do //设置属性
begin
AutoSize:=True;
AutoStretch:=True;
Alignment:=taLeftJustify;
Left:=LeftValue;
// Caption:=frm_find.ADOQuery1.fields[i].FieldName;
Caption:=frm_find.DBGrid1.Columns[i].Title.Caption;
Top:=10;
Height:=14;
LeftValue:=Width+LeftValue+10;
end;
end;
LeftValue:=0;
for i:=0 to FieldCount-1 do
begin
MyText:=TQRDBText.Create(frm_find_report);
with frm_find_report do
MyText.Parent:=QRBand2;// QRSubDetail1;
with MyText do
begin
Dataset:=frm_find.ADOQuery1;
DataField:=frm_find.ADOQuery1.Fields[i].AsVariant;
AutoSize:=True;
AutoStretch:=True;
Alignment:=taLeftJustify;
Left:=LeftValue;
Top:=10;
Height:=14;
LeftValue:=Width+LeftValue+10;
end;
end;
frm_find_report.Show;
frm_find_report.QuickRep1.Preview;end;
var
MyLabel: TQRLabel;
MyText:TQRDBText;
FieldCount,i,LeftValue:integer;begin
Fieldcount:=frm_find.ADOQuery1.FieldCount;
leftValue:=0;
frm_find_Report.QuickRep1.DataSet:=frm_find.ADOQuery1;
for i:=0 to Fieldcount-1 do
begin
MyLabel:=TQRLabel.Create(frm_find_Report);
with frm_Find_Report do
MyLabel.Parent:=QRBand1;// HeaderBand1; //放在HeaderBand(rbDetail)里
with MyLabel do //设置属性
begin
AutoSize:=True;
AutoStretch:=True;
Alignment:=taLeftJustify;
Left:=LeftValue;
// Caption:=frm_find.ADOQuery1.fields[i].FieldName;
Caption:=frm_find.DBGrid1.Columns[i].Title.Caption;
Top:=10;
Height:=14;
LeftValue:=Width+LeftValue+10;
end;
end;
LeftValue:=0;
for i:=0 to FieldCount-1 do
begin
MyText:=TQRDBText.Create(frm_find_report);
with frm_find_report do
MyText.Parent:=QRBand2;// QRSubDetail1;
with MyText do
begin
Dataset:=frm_find.ADOQuery1;
DataField:=frm_find.ADOQuery1.Fields[i].AsVariant;
AutoSize:=True;
AutoStretch:=True;
Alignment:=taLeftJustify;
Left:=LeftValue;
Top:=10;
Height:=14;
LeftValue:=Width+LeftValue+10;
end;
end;
frm_find_report.Show;
frm_find_report.QuickRep1.Preview;end;
第二个就是QuickRep1,以及detial band 的dataset中少指定了一个.