QRDBText2.Left:=QRDBText1.Left+QRDBText1.Width+N;
//N为间距,通过实验确定
Left和Width属性可是很有用的哟。
我用的是Band,下面这段代码实现了指定字段间距以及打印的居中。
with QuickRep1.Bandsdo
begin
for i:=1 to ColumnHeaderBand.ControlCount-1do
begin
//PrintSpace为间距
ColumnHeaderBand.Controls.Left:=PrintSpace+ColumnHeaderBand.Controls[i-1].Left+ColumnHeaderBand.Controls[i-1].Width;
DetailBand.Controls.Left:=ColumnHeaderBand.Controls.Left;
end;
i:=ColumnHeaderBand.ControlCount-1;
n:=ColumnHeaderBand.Controls.Width;
Inc(n,ColumnHeaderBand.Controls.Left);
end;
if w>n+12 then
//w为页面的宽度(像素),n为打印字段占用的宽度
n:=(w-n-6) div 2
else
n:=0;
if n>2 then
begin
//整体右移以居中
for i:=0 to QuickRep1.Bands.ColumnHeaderBand.ControlCount-1do
begin
with QuickRep1.Bands.ColumnHeaderBand.Controlsdo
Left:=Left+n;
with QuickRep1.Bands.DetailBand.Controlsdo
Left:=Left+n;
end;
end;