I am facing problem in grid control while printing it. I want to print and preview multiple grid on the same page. when a grid length goes out the paper width, the remaining portions of the grid is not printed or previewed in the next page. Here i attached a sample to replicate the problem. Please let me know, how to handle the above problem.
ADAdministrator Syncfusion Team July 16, 2004 02:29 AM
I do not have a solution for this.
To get things to work, in your OnPrintPage, you would have to flag the situation where the grid did not fit, somehow remembering what did not fit. Then tell the printing framework that another page is needed by setting ev.HasMorePages to true. Then when OnPrintPage is call for the second time, print the piece that did not fit on th efirst page. Currently, this will take some coding and time to work out the details.
Another option, might be to use the technique from the PrintToFit sample to force everything to fit on a page by shrinking it. This may be simpler to do.
SUSureshManiJuly 19, 2004 02:53 AM
I used the HasMorePages property in the OnPrintPage. But when the method called another time for the new page i cannot able to print the remaining protions of the grid control. Is there any provisions in the grid control to remeber how many row are printed and how many columns are printed. Here i attached a sample applciation which uses the HasMorePages property, but still i cannot able to solve the problem. Let me know the solution.
ADAdministrator Syncfusion Team July 19, 2004 03:55 AM
>>Is there any provisions in the grid control to remeber how many row are printed and how many columns are printed
No, not currently. You would have to compute the number of columns that can be printed using the size of the rectangle on the printer page that you have allocated to the grid.
For example, I suspect you would have to loop through the columns, say on ColIndex, until grid.Model.ColWidths.GetTotal(0, ColIndex) exceeded the width of the rectangle you have allocated for this grid. Then you would know that ColIndex - 1 is the index of the last column that will fit.
You would still have the problem of how to only print 0 through ColIndex-1 columns. One way you could do this is to have the derived printdocument subscribe to the grid.Model.QueryColWidth event. In your handler, if e.Index >= ColIndex, then set e.Size = 0 and e.Handled - true. This will dynamically hide the columns you do not want printed on this page. Then when you are printing page 2, you would hide the columns where e.Index < ColIndex.
If you handle QueryColWidth in the PrintDocument, you would want to make sure the event was unsubscribe as the printdocument went out of scope.