We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

PrintingMode property not set during FitToPage printing

I am using a modified version of the FitToPage sample, where I try to fit the grid on a page, but if it''s over a certain number of rows, I only print some of the grid, shrunk to the page, then let the remainder spill onto the next pages. This means that I''m overriding the OnPrintPage method. It seems that in the grid source code, this method is where the PrintingMode property is set to true at the top, false at the bottom. Since my virtual grid QueryCellInfo handler needs to do different things if we''re printing or not, I need that flag to be set properly. I tried setting the PrintingMode property on my own in the overridden OnPrintPage, but it has side effects. When I print preview the grid, it doesn''t show up, then when I come back, my grid on the form only shows about the left 75%, the rest of the grid is white. (I suspect the grid source is looking at that PrintingMode property as well, maybe with the GridBounds, etc?) Bottom line - do I have to set my own static variable somewhere that tells my QueryCellInfo handler that we''re printing? Or is there some better place to set PrintingMode to true before, and false after? (sorry for the length of the message - hope it makes sense)

2 Replies

AD Administrator Syncfusion Team August 27, 2004 12:57 AM UTC

In our code, PrintingMode is turned on at the beginning of both OnBeginPrint and OnPrintPage. In is also turned off at the end of each of these methods. So, in overrides of either of these methods, if you turn it on, and then call the baseclass, it will come back turned off after the baseclass call. If this is why it is off when you check it in your code, you could try resetting it true after the baseclass call returns. If that does not make things work, I would just try a static member just to see if that would handle things. If it does, and you do not want to use a static member, you could derive the grid and add your own printing flag.


AD Administrator Syncfusion Team August 27, 2004 05:42 AM UTC

One other comment about the grid not using the proper GridBounds after doing the PrintToFit code. Instead restoring the GridBounds to a saved rectangle as the sample does, just try calling grid.ResetGridBounds.

Loader.
Live Chat Icon For mobile
Up arrow icon