Printing With TmsFmxGrid

Is there any body who can tell me

How Can I control the size and The location of the TMSFMXGRID(Firemonkey) printed on the paper?

For example I wish my grid to be centered on the Paper!

Thank you in Advance


You can add an offset under grid options:


Kind Regards, 

How ever I still have to center my grid inside the paper. I can get the Dimensions of the paper but I have no idea about how to get the dimensions of my grid on the paper, so I can not determine the appropriate value of Options....Margins.Left

Please Help!!

Please Pieter, don't let me down. I expected some Help from an Expert!!

How can I center my grid on a Printed Paper??? How can I control The Size of This Printed Grid???


You can use the following code to center the grid:

  totsize := 0;
  for I := 0 to TMSFMXGrid1.ColumnCount - 1 do
    totsize := totsize + TMSFMXGrid1.ColumnWidths;
    if totsize + TMSFMXGrid1.ColumnWidths > Printer.PageWidth then

  TMSFMXGrid1.Options.Printing.PrintMargins.Left := (Printer.PageWidth - totsize) / 2;

Kind Regards, 

I appreciate that.

What about controlling the size of the Printed Grid. I noticed that some times my Grid Exceeds the dimensions of the paper? I wish be able to decrease the size by code....

Please Stay with me!

Sorry, the size of the printed grid is currently not configurable, it is printed as is and if the grid detects the edge minus the print margins the grid automatically draws it cells on the next page.

Kind Regards, 

What about the line Grid22.Options.Printing.DPI.SetLocation(400,400);

when I used it the grid became smaller on the page. My Problem well be resolved if you tell how to relate the width of the grid to these two parameters (400,400). What I need is scaling only the width of the grid to fit the page.


The DPI is not related to the width of the grid, values that are accepted depend on the supported DPI of your printer.

Another approach would be to use the MakeScreenShot functionality and print the bitmap directly on the canvas of the printer instead:


But this will only work if you do not have any scrolling columns / rows

Kind Regards, 

I agree with you, I used MakeScreenShot functionality, but I do have scrolling columns.

Let me ask the Question in this way:

Is there a way to determine the width of the grid before it is transported to the page???

[   if I know Grid1.Width on the screen   then   Grid1.Width on the page = ? ]