procedure TForm1.frxReport1BeforePrint(c: TfrxReportComponent); var Cross: TfrxCrossView; i, j: Integer; begin //检查报表里内的控件是否为TfxCrossView if c is TfrxCrossView then begin Cross := TfrxCrossView(c); Table1.First; i := 0; while not Table1.Eof do begin for j := 0 to Table1.Fields.Count - 1 do Cross.AddValue([i], [Table1.Fields[j].DisplayName], [Table1.Fields[j].AsString]); Table1.Next; Inc(i); end; end; ///给标题赋值 if c is TfrxMemoView then begin if c.Name='Title' then TfrxMemoView(c).Text:='wtwtest'; end; end;
页头上放个Memo,在该Memo的OnBeforePrint事件中加入代码 if <page>=2 then begin Memo.visible:=false; end;
var
Cross: TfrxCrossView;
i, j: Integer;
begin
//检查报表里内的控件是否为TfxCrossView
if c is TfrxCrossView then
begin
Cross := TfrxCrossView(c); Table1.First;
i := 0;
while not Table1.Eof do
begin
for j := 0 to Table1.Fields.Count - 1 do
Cross.AddValue([i], [Table1.Fields[j].DisplayName], [Table1.Fields[j].AsString]); Table1.Next;
Inc(i);
end;
end;
///给标题赋值
if c is TfrxMemoView then begin
if c.Name='Title' then TfrxMemoView(c).Text:='wtwtest';
end;
end;
if <page>=2 then
begin
Memo.visible:=false;
end;
这样只会在第一页显示