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

custom grid print class

Hi, I''m writing a custom class to handle grid printing. What it needs to do is to accept an array of grids to print and display them all (not on the same page) correctly in a print preview window to the user with header and footer text. The KB articles were extremely helpful but didn''t completely get me what I wanted. I''m calculating the start/end rows and the start/end columns for each page then using OnDrawClientRowCol to draw the grid onto print graphics object. This works fine for grids that only take up one page. When I try to print a grid that takes up two pages it doesn''t work. What is happening on a grid with 99 rows it prints the first page correctly but the second page it prints the header row and rows 1 and 2 and nothing else from the grid. I have verified that I am passing rows 1-51 into the first page and rows 52-99 on the second page in the OnDrawClientRowCol parameters. I am having similar problems on printing a grid with columns that need to be printed on a second page. The first page is correct but the second page has the columns from the first page and the columns for the second page added to the end to the edge of the print page. What do I need to do to get OnDrawClientRowCol to correctly draw the second pages for these grids? Or do I need to use another method to draw the grid onto the print graphic? Thanks, Gordon

5 Replies

AD Administrator Syncfusion Team November 16, 2004 04:16 PM UTC

Before calling OnDrawClientRowCol, make sure grid.PrintingMode = true. Then explicilty set grid.PrintInfo.m_awPageFirstCol and grid.PrintInfo.m_awPageFirstRow to point to your top-left cell for the page.

GR Gordon Rhea November 16, 2004 04:51 PM UTC

I''m still having a similar problem. The only difference is that now page 2 is showing no rows instead of rows 1 and 2. I''m attaching a sample app that shows what''s going on. Thanks, Gordon GridPrintTest_8330.zip

AD Administrator Syncfusion Team November 16, 2004 10:57 PM UTC

The OnDrawClientRowCol method accepts client rows, so you cannot pass in abosute rows like 51 to 100. It is always something like 0 to 50. If you own the source code, you can check out the code in GridPrintDocument.OnPrintPage. It uses OnDrawClienRowCol, but always passes in 0, 0, bottomRow, rightCol. The code preceding the call sets things up so the call prints properly. I think you will have to try to use the same technique in your code to set up the call.

GR Gordon Rhea November 17, 2004 02:42 PM UTC

Thanks Clay. Calculating the client rows fixed the problems. Gordon

MS miles stone April 6, 2022 11:26 AM UTC

Thanks for the useful info

Live Chat Icon For mobile
Up arrow icon