H
hhw_dxzx
Unregistered / Unconfirmed
GUEST, unregistred user!
用QReport分栏,一行打印五个内容,具体代码如下:
BeforePrint事件化代码:
procedure TPrintForm.QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
begin
MainForm.ADOQuery1.First;
end;
NeedData事件代码:
procedure TPrintForm.QuickRep1NeedData(Sender: TObject;
var MoreData: Boolean);
var I:integer;
name:string;
begin
MoreData:= True;
for I:= 1 to 5do
begin
if MainForm.ADOQuery1.Eof then
Break;
case I of
1:begin
QRLabel1.Caption := MainForm.ADOQuery1.FieldByName('xjh').AsString;
QRLabel6.Caption := MainForm.ADOQuery1.FieldByName('xm').AsString;
name:=photopath+'pt'+MainForm.Adoquery1.fieldbyname('xjh').AsString+'.jpg';
if fileexists(name) then
QRImage1.Picture.LoadFromFile(name)
else
QRImage1.Picture:=nil;
end;
2:begin
QRLabel2.Caption := MainForm.ADOQuery1.FieldByName('xjh').AsString;
QRLabel7.Caption := MainForm.ADOQuery1.FieldByName('xm').AsString;
name:=photopath+'pt'+MainForm.Adoquery1.fieldbyname('xjh').AsString+'.jpg';
if fileexists(name) then
QRImage2.Picture.LoadFromFile(name)
else
QRImage2.Picture:=nil;
end;
3:begin
QRLabel3.Caption := MainForm.ADOQuery1.FieldByName('xjh').AsString;
QRLabel8.Caption := MainForm.ADOQuery1.FieldByName('xm').AsString;
name:=photopath+'pt'+MainForm.Adoquery1.fieldbyname('xjh').AsString+'.jpg';
if fileexists(name) then
QRImage3.Picture.LoadFromFile(name)
else
QRImage3.Picture:=nil;
end;
4:begin
QRLabel4.Caption := MainForm.ADOQuery1.FieldByName('xjh').AsString;
QRLabel9.Caption := MainForm.ADOQuery1.FieldByName('xm').AsString;
name:=photopath+'pt'+MainForm.Adoquery1.fieldbyname('xjh').AsString+'.jpg';
if fileexists(name) then
QRImage4.Picture.LoadFromFile(name)
else
QRImage4.Picture:=nil;
end;
5:begin
QRLabel5.Caption := MainForm.ADOQuery1.FieldByName('xjh').AsString;
QRLabel10.Caption := MainForm.ADOQuery1.FieldByName('xm').AsString;
name:=photopath+'pt'+MainForm.Adoquery1.fieldbyname('xjh').AsString+'.jpg';
if fileexists(name) then
QRImage5.Picture.LoadFromFile(name)
else
QRImage5.Picture:=nil;
end;
end;
MainForm.ADOQuery1.Next;
end;
if MainForm.ADOQuery1.Eof then
MoreData:= False;
end;
如果记录的条数不是5的倍数,余下的记录将打印不出来。比如有61条记录,只能打印出前
60条,每行5个,第61条记录不能打印出。也就是说最后一行不足5个的内容将不被打印。请教各位高手此中的原因,如何解决?
BeforePrint事件化代码:
procedure TPrintForm.QuickRep1BeforePrint(Sender: TCustomQuickRep;
var PrintReport: Boolean);
begin
MainForm.ADOQuery1.First;
end;
NeedData事件代码:
procedure TPrintForm.QuickRep1NeedData(Sender: TObject;
var MoreData: Boolean);
var I:integer;
name:string;
begin
MoreData:= True;
for I:= 1 to 5do
begin
if MainForm.ADOQuery1.Eof then
Break;
case I of
1:begin
QRLabel1.Caption := MainForm.ADOQuery1.FieldByName('xjh').AsString;
QRLabel6.Caption := MainForm.ADOQuery1.FieldByName('xm').AsString;
name:=photopath+'pt'+MainForm.Adoquery1.fieldbyname('xjh').AsString+'.jpg';
if fileexists(name) then
QRImage1.Picture.LoadFromFile(name)
else
QRImage1.Picture:=nil;
end;
2:begin
QRLabel2.Caption := MainForm.ADOQuery1.FieldByName('xjh').AsString;
QRLabel7.Caption := MainForm.ADOQuery1.FieldByName('xm').AsString;
name:=photopath+'pt'+MainForm.Adoquery1.fieldbyname('xjh').AsString+'.jpg';
if fileexists(name) then
QRImage2.Picture.LoadFromFile(name)
else
QRImage2.Picture:=nil;
end;
3:begin
QRLabel3.Caption := MainForm.ADOQuery1.FieldByName('xjh').AsString;
QRLabel8.Caption := MainForm.ADOQuery1.FieldByName('xm').AsString;
name:=photopath+'pt'+MainForm.Adoquery1.fieldbyname('xjh').AsString+'.jpg';
if fileexists(name) then
QRImage3.Picture.LoadFromFile(name)
else
QRImage3.Picture:=nil;
end;
4:begin
QRLabel4.Caption := MainForm.ADOQuery1.FieldByName('xjh').AsString;
QRLabel9.Caption := MainForm.ADOQuery1.FieldByName('xm').AsString;
name:=photopath+'pt'+MainForm.Adoquery1.fieldbyname('xjh').AsString+'.jpg';
if fileexists(name) then
QRImage4.Picture.LoadFromFile(name)
else
QRImage4.Picture:=nil;
end;
5:begin
QRLabel5.Caption := MainForm.ADOQuery1.FieldByName('xjh').AsString;
QRLabel10.Caption := MainForm.ADOQuery1.FieldByName('xm').AsString;
name:=photopath+'pt'+MainForm.Adoquery1.fieldbyname('xjh').AsString+'.jpg';
if fileexists(name) then
QRImage5.Picture.LoadFromFile(name)
else
QRImage5.Picture:=nil;
end;
end;
MainForm.ADOQuery1.Next;
end;
if MainForm.ADOQuery1.Eof then
MoreData:= False;
end;
如果记录的条数不是5的倍数,余下的记录将打印不出来。比如有61条记录,只能打印出前
60条,每行5个,第61条记录不能打印出。也就是说最后一行不足5个的内容将不被打印。请教各位高手此中的原因,如何解决?