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)
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.
AdministratorAugust 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.