Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
  • Lazarus Lazarus
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 2,102
    • Issues 2,102
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
  • Merge requests 9
    • Merge requests 9
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • External wiki
    • External wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • FPC
  • LazarusLazarus
  • LazarusLazarus
  • Issues
  • #37021
Closed
Open
Issue created May 05, 2020 by FPC Admin account@fpc_adminOwner

Add new event in TFrPrintGrid

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
Assignee
Assign to
Time tracking