DEVEXPRESS - xtrareport - page break

邮差的信 提交于 2019-12-06 03:19:20

问题


I have a datatable with more than 300 rows. I want each page to present only 10 rows in it. I want to force the xtrareport to break after 10 rows.

Any idea on how this is done ?


回答1:


You can force a page break on certain conditions. This page has an example at the bottom.

Hi Cary,

To accomplish this task you can either add a GroupFooter band and set the GroupFooter.PageBreak to AfterBand. or put a XRPageBreak control, handle the Detail.BeforePrint and adjust the visibility of the XRPageBreak as you need. To get processing row you need to use the XtraReport.GetCurrentRow() method. Please try this solution, and let us know the results.

Thanks,
Andrew




回答2:


you need to create a Repport Merging.

  • The first step is to create a main Repport.
  • Then, create a second Repport every 10 rows.
  • And, add this second Repport in the main Repport.

here is an example :

private void printInvoicesButton_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
    {
        int[] selection = this.ordersGridView.GetSelectedRows();
        XtraReport reportMerge = new XtraReport();
        reportMerge.CreateDocument();

        IList<XtraReport> reportList = new List<XtraReport>();

        // Create a report.
        //invoiceReport report = new invoiceReport();

        for (int j = 0; j < selection.Length; j++)
        {


            XtraReport report = new XtraReport();
            string filePath = @"Reports/invoiceReport1.repx";
            report.LoadLayout(filePath);


            InvoiceData invoice = new InvoiceData();

            for (int i = 0; i < DataRepository.Orders.Orders.Count; i++)
            {
                if (
                    ordersGridView.GetRowCellValue(selection[j], "InvoiceCode").Equals(
                        DataRepository.Orders.Orders[i].InvoiceCode))
                {
                    BindingSource dataSource = new BindingSource();

                    invoice = InvoiceData.AdaptFrom(DataRepository.Orders.Orders[i], DataRepository.Orders,
                                                    DataRepository.Products.Products,
                                                    DataRepository.ProductOptionMaster,
                                                    DataRepository.ProductOptionDataSet,
                                                    DataRepository.CustomerShippingAddresses,
                                                    DataRepository.Customers.UserMaster,
                                                    DataRepository.AttributesData.Product_Attributes);

                    dataSource.Add(invoice);

                    report.DataSource = dataSource;
                    //report.ShowPreview();
                    report.CreateDocument();

                }
            }
            reportList.Add(report);
        }

        for(int i=0;i<reportList.Count;i++)
        {
            reportMerge.Pages.AddRange(reportList[i].Pages);
        }

        // Show the report's preview.
        reportMerge.ShowPreviewDialog();            

    }


来源:https://stackoverflow.com/questions/9700059/devexpress-xtrareport-page-break

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!