Hi,
I want to print a form with xamGrid on it (not xamDataGrid because it does not support cell merging). Since xamGrid does not support report paging, I do paging manually - scroll grid to specified row and print it using Report.Print(), where grid is used as visual report section :
(Report.Sections.Add(new EmbeddedVisualReportSection(xamGrid))
and do it page by page. I do scrolling using
xamGrid.ScrollCellIntoView(xamGrid.Rows[firstPageRow].Cells[0])
The last row of the printed grid is usually lost, only narrow top part of it is visible, something like this:
I can fix it by scrolling grid on page size - 1 between the pages.In this case sometimes I have duplicate records on two pages but not a missing row. The problem is in the last row of the last page, it always truncated at the bottom. Is it possible to fix it ?
Thanks,
Ed
Hi Ed,
I tried putting together a sample but I'm stuck on trying to figure out exactly how you are printing the XamGrid per page. At first I thought you were just doing something like this:
report.Sections.Add(new EmbeddedVisualReportSection(xamGrid)); xamGrid.ScrollCellIntoView(xamGrid.Rows[firstPageRow].Cells[0]); report.Sections.Add(new EmbeddedVisualReportSection(xamGrid)); xamGrid.ScrollCellIntoView(xamGrid.Rows[secondPageRow].Cells[0]); report.Sections.Add(new EmbeddedVisualReportSection(xamGrid)); xamGrid.ScrollCellIntoView(xamGrid.Rows[thirdPageRow].Cells[0]); report.Sections.Add(new EmbeddedVisualReportSection(xamGrid));
Where basically you add to the report, then call ScrollCellIntoView, then add the grid again, etc etc. But when I do this, my first page looks correct but all the pages after it have scrolled all the way to the bottom rather than gradually scrolling down. It seems like it's using the last XamGrid state for all pages but the first one.
So my question to you is, how exactly are you printing this grid? Can you post your print code for me?
Hi Rob,
I print in the loop, and inside the loop I create new Report object, initialize it, scroll the grid, set visual page section and print. Something like this:
int pageSize = getPageSize(xamGrid);
// scroll grid to the beginning //xamGrid.ScrollCellIntoView(xamGrid.Rows[0].Cells[0]);
int firstPageRow = 0;
while (true) { // scroll to the next page xamGrid.ScrollCellIntoView(xamGrid.Rows[firstPageRow].Cells[0]);
// print corresponding page in a separate report Report objReport = new Report(); ReportProgressControl progress = new ReportProgressControl(); objReport.PageHeaderTemplate = HeaderTemplate; objReport.PageFooterTemplate = FooterTemplate; objReport.ReportSettings.Margin = new Thickness(MARGIN, MARGIN, MARGIN, MARGIN); objReport.ReportSettings.HorizontalPaginationMode = HorizontalPaginationMode.Scale;objReport.ReportSettings.PageOrientation = orientation;
objReport.Sections.Add(new EmbeddedVisualReportSection(xamGrid));
objReport.ReportSettings.RepeatType = RepeatType.PageBreak; objReport.PageHeader = header; progress.Report = objReport;
objReport.Print(showPrintDialog, showProgressBar);
if (xamGrid.Rows[xamGrid.Rows.Count - 1].Cells[0].Control != null) // last page - last grid row is visible { break; }
firstPageRow = Math.Min(firstPageRow + pageSize + (pageSize-2), xamGrid.Rows.Count - 1); }
Sorry for the late reply. I didn't see the email from when you responded.
Your firstPageRow calculation looks a bit odd to me. When I used the code, I was getting some weird results where large numbers of rows are being skipped after about 2 pages had been printed. I have adjusted the calculate so that it will print pages correctly. I have attached a sample I used for testing this.
In my sample, I printed to XPS so that I would not have to use an actual printer for my testing and it printed all the pages correctly. I numbered my rows so I could make sure that rows were not being skipped.
For now I changed my scrolling procedure and I resolved the last page issue by adding dummy empty record to the end of collection binded to the grid.
Thanks for your help,
Let me know if you have any further questions on this matter.