给一个实现的完整例子
procedure TForm1.frxReport1BeforePrint(Sender: TfrxReportComponent);
var
emptypic,picpath:string;
begin
picpath:=ExtractFilePath(Application.ExeName)+ 'pic/'+
labelededit1.Text+'/'+adoquery1.FieldValues['bmh']+'.jpg';
emptypic:=ExtractFilePath(Application.ExeName)+ 'pic/'+
labelededit1.Text+'/00000000000000'+'.jpg';
if (sender is TFrxPictureView) and (sender.Name='Picture1') then
begin
with (sender as TFrxPictureView)do
if FileExists(picpath) then
Picture.LoadFromFile(picpath)
else
Picture.LoadFromFile(emptypic) ;
end;
end;
早期版本的fastreport则应该这样写(注意fastreport本身有修改,所以参数不一样了)
procedure TForm1.frReport1BeforePrint(Memo: TStringList;
View: TfrView);
begin
//加载照片
if View.Name = 'Picture2' then
if FileExists('photo/'+ado_dt1.FieldValues['bmh'] +'.jpg') then
TfrPictureView(View).Picture.LoadFromFile('photo/'+ado_dt1.FieldValues['bmh'] +'.jpg')
else
TfrPictureView(View).Picture.LoadFromFile('photo/1111111111.jpg')
end;