Add new event in TFrPrintGrid
Original Reporter info from Mantis: zgabrovski
-
Reporter name: Zdravko Gabrovski
Original Reporter info from Mantis: zgabrovski
- Reporter name: Zdravko Gabrovski
Description:
TFRPrintGrid is famous component, that helps a lot for a simple DBGrid Preview/Print.
I case of my project needs, I add a new event handler, Called "OnFinalSetup", which is executed just before internal FRReport preview in PreviewReport method.
The new event pass by reference allready created internal FRReport and FColumnsInfo.
It will give to developer an option to do changes (if necessary) of internal FRReport component, or to adjust columns - for example - columns width - based on calculations over already created FRReport component, which is not accessible..
In my case, I am using this to fit a grid inside report page with following sample code:
procedure TfSingleGridResult.rpPrintGridFinalSetup(Sender: TFrPrintGrid;
var FReport: TfrReport; var FColumnsInfo: TColumnInfoArr);
var
Page: TfrPage;
lWidth: Single;
OldTotalWidth , i: Integer;
ColInfo: TColumnInfo;
Coeff : Single;
begin
if not cbFit.Checked then
Exit;
if FReport.Pages.Count > 0 then begin
// Calculate NEW column widths
Page := FReport.Pages[FReport.Pages.Count-1];
lWidth := Page.Width*1.17;
OldTotalWidth := 0;
For ColInfo in FColumnsInfo do
OldTotalWidth := OldTotalWidth + Colinfo.ColumnWidth;
Coeff := lWidth / OldTotalWidth;
For i := 0 to Length( FColumnsInfo )-1 do
FColumnsInfo[ i ].ColumnWidth := Round( FColumnsInfo[ i ].ColumnWidth * Coeff );
end;
end;
Mantis conversion info:
- Mantis ID: 37021
- Build: trunk
- Fixed in version: 2.0.10
- Fixed in revision: 63182 (#9cdfd55e)
- Target version: 2.0.10