段纯动态创建,找对你有用的来:
procedure TForm1.BitBtn1Click(Sender: TObject);
var
i:integer;
leftx:integer;
widthperbyte:integer;
Heading:TQRlabel;
QRLabel: TQRlabel;
QRshape1: TQRshape;
QRshape2: TQRshape;
QRdbtext: TQRDBtext;
qrexpr :TQRExpr ;
begin
widthperbyte:=10;
columnswidth;
disposecontrols;
if totalwidth*widthperbyte>1123 then
begin
Application.MessageBox('±¨±í3??í,??μ÷???ùê?3?£?','?ˉ??',1);//ê?3????°?ò
exit;
end
else
if totalwidth*widthperbyte>794 then
unit2.Form2.QuickRep1.Page.Orientation:=polandscape //oá?ò
else
unit2.Form2.QuickRep1.Page.Orientation:=poPortrait;//×Y?ò
Heading:=TQRlabel.Create(self);
//′′?¨TQRlabel???t
Heading.parent:=unit2.Form2.TitleBand1;
//éè????èY?÷???t
Heading.Caption:='?§éú??3ì3é?¨±í';
//±¨±í±êìa
Heading.Font.Size:=16;
Heading.Font.Style:=[fsbold];
Heading.Alignment:=tacenter;
Heading.Width:=Length('?§éú??3ì3é?¨±í')*(widthperbyte+4);
Heading.Left:=(unit2.Form2.QuickRep1.Width-Heading.width)div 2;
Heading.Height:=unit2.Form2.TitleBand1.Height -1 ;
Heading.Top:=0;
Leftx:=(unit2.Form2.quickrep1.width-totalwidth*widthperbyte)div 2;
for i:=0 to Listbox2.items.count-1do
//?ù?Y?ù????×???μ?êy??à′?ˉì?′′?¨
begin
QRShape1:=TQRSHape.Create(self);
QRShape1.parent:=unit2.Form2.ColumnHeaderBand;
QRShape1.Left:=Leftx;
QRShape1.Width:=maxwidth*widthperbyte+4;
QRShape1.Height:=unit2.Form2.ColumnHeaderBand.Height;
QRShape1.top:=0;
QRLabel:=TQRLabel.Create(self);
QRLabel.parent:=unit2.Form2.ColumnHeaderBand;
QRLabel.Font.Style:=[fsbold];
QRLabel.Left:=Leftx+2;
QRLabel.width:=maxwidth*widthperbyte;
QRLabel.height:=unit2.Form2.ColumnHeaderBand.Height;
QRLabel.top:=1;
QRLabel.caption:=Listbox2.Items.Strings;
QRShape2:=TQRSHAPE.Create(self);
QRShape2.Parent:=unit2.Form2.DetailBand1;
QRShape2.Left:=Leftx ;
QRShape2.Width:=maxwidth*widthperbyte+4;
QRShape2.Height:=unit2.Form2.DetailBand1.Height ;
QRShape2.top:=0;
QRDBText:=TQRDBText.Create(self);
QRDBText.parent:=unit2.Form2.DetailBand1;
QRDBText.Left:=Leftx+2;
QRDBText.Width:=maxwidth*widthperbyte;
QRDBText.Height:=unit2.Form2.DetailBand1.Height -2;
QRDBText.Top:=1;
QRDBText.DataSet:=unit1.Form1.ADOQuery1;
QRDBText.DataField:=Listbox2.Items.Strings;
Leftx:=Leftx+maxwidth*widthperbyte+4;
end;
qrexpr:=TQRexpr.Create(self);
qrexpr.Left:=10;
unit2.Form2.QuickRep1.PreviewModal;
end;
procedure disposecontrols;
var i:integer;
begin
for i:=0 to unit2.Form2.TitleBand1.ControlCount-1do
//è????μí3?????tμ?????
unit2.Form2.TitleBand1.RemoveControl(unit2.Form2.TitleBand1.Controls[0]);
for i:=1 to unit2.Form2.ColumnHeaderBand.ControlCountdo
unit2.Form2.ColumnHeaderBand.RemoveControl(unit2.Form2.ColumnHeaderBand.Controls[0]);
for i:=1 to unit2.Form2 .DetailBand1.ControlCount do
unit2.Form2.DetailBand1.RemoveControl(unit2.Form2.DetailBand1.Controls[0]);
end;