2012-03-14 59 views
5

Tôi có một giá trị dữ liệu với hơn 300 hàng. Tôi muốn mỗi trang chỉ hiển thị 10 hàng trong đó. Tôi muốn bắt buộc xtrareport phá vỡ sau 10 hàng.DEVEXPRESS - xtrareport - ngắt trang

Bất kỳ ý tưởng nào về cách thực hiện điều này?

Trả lời

4

Bạn có thể buộc một ngắt trang trên một số điều kiện nhất định. This page có ví dụ ở dưới cùng.

Hi Cary,

Để thực hiện nhiệm vụ này, bạn có thể thêm một ban nhạc GroupFooter và thiết lập GroupFooter.PageBreak để AfterBand. hoặc đặt điều khiển XRPageBreak, xử lý Detail.BeforePrint và điều chỉnh mức hiển thị của XRPageBreak khi bạn cần. Để có được hàng xử lý, bạn cần sử dụng phương thức XtraReport.GetCurrentRow(). Vui lòng thử giải pháp này và cho chúng tôi biết kết quả.

Cảm ơn,
Andrew

+1

đơn giản và thanh lịch. cảm ơn bạn. – Fares

5

bạn cần phải tạo ra một Ghép Repport.

  • Bước đầu tiên là tạo mối quan hệ chính.
  • Sau đó, tạo Mối quan hệ thứ hai sau mỗi 10 hàng.
  • Và thêm mối quan hệ thứ hai này vào Mối quan hệ chính.

đây là một ví dụ:

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();    

    } 
Các vấn đề liên quan