HenryM2
asked on
Delphi Rave Reports How do you link the CurrentPage and Pages Properties to TRVSystem Component
Using Code Based Rave Reports in Delphi, how do I display the CurrentPage Number and Total Pages in a report? I have a TRVSystem component but the CurrentPage and Pages property is linked to the TRvRenderPreview component.
ASKER
I am using this line:
PrintCenter('Page ' + IntToStr(CurrentPage) + ' Of ' + IntToStr(Pages), PageWidth/2);
The compiler is happy with (CurrentPage) works but it reports (Pages) is reported as Undeclared Identifier..
the problem is how to know amount of pages if is still printing
it seems you have to generate first, save page count into variable and then generate it again. Here is example:
procedure TForm1.Button1Click(Sender : TObject);
begin
RvSystem1.Generate; // generates only for getting page count
RvSystem1.Execute; // the second for preview
end;
var
Pages: Integer;
procedure TForm1.RvSystem1AfterPrint (Sender: TObject);
begin
Pages:= (Sender as TBaseReport).CurrentPage;
end;
procedure TForm1.RvSystem1Print(Send er: TObject);
procedure PrintGridHeader;
var
iCol: Integer;
curY: Double;
begin
with Sender as TBaseReport do
begin
if CurrentPage <> 1 then
PrintCenter(IntToStr(Curre ntPage) + IntToStr(Pages), PageWidth/2);
......
it seems you have to generate first, save page count into variable and then generate it again. Here is example:
procedure TForm1.Button1Click(Sender
begin
RvSystem1.Generate; // generates only for getting page count
RvSystem1.Execute; // the second for preview
end;
var
Pages: Integer;
procedure TForm1.RvSystem1AfterPrint
begin
Pages:= (Sender as TBaseReport).CurrentPage;
end;
procedure TForm1.RvSystem1Print(Send
procedure PrintGridHeader;
var
iCol: Integer;
curY: Double;
begin
with Sender as TBaseReport do
begin
if CurrentPage <> 1 then
PrintCenter(IntToStr(Curre
......
ASKER
Yes, this is one way. The other way I thaught about to get the number of pages would be to take the number of rows in the StringGrid and Div it by 50 (50 lines per page) + 1.
The idea of pages, however came form the Rave Report manual. Below, a screen print from the manual. Is this not an option?
Rave-Report-Pages-Property.png
The idea of pages, however came form the Rave Report manual. Below, a screen print from the manual. Is this not an option?
Rave-Report-Pages-Property.png
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
> Pages:= (StringGrid1.RowCount div 50);
> if (StringGrid1.RowCount mod 50) > 0 then Inc(Pages);
This kind of thing is generally done in one single step :
Pages:= ( Count + NbPerPage -1 ) Div NbPerPage;
in you case :
> if (StringGrid1.RowCount mod 50) > 0 then Inc(Pages);
This kind of thing is generally done in one single step :
Pages:= ( Count + NbPerPage -1 ) Div NbPerPage;
in you case :
Pages:= (StringGrid1.RowCount+49) div 50;
Thanks Epasquier
I suspected that it can be done in one string, but was too tired to think
I suspected that it can be done in one string, but was too tired to think
ASKER
Thanks to both of you. Well as they say, there is many ways to skin a cat, perhaps some a bit more elegant than others, but the main thing is that my program is working very well.
procedure PrintGridHeader;
....
with Sender as TBaseReport do
begin
if CurrentPage <> 1 then // don't show page number on the first page (just for example)
PrintCenter(IntToStr(Curre