Report Design: How to use report script to set number of items to be printed per page

From AutoCount Resource Center
Jump to navigation Jump to search

Question : How can I use report script to set only 10 items to be printed per page for Invoice?

Pagebreak1.png


Answer :

1) Go to Sales > Invoice, click on Report > Design Document Style Report.

Pagebreak2.png


2) Select the report name and click on Design.

Pagebreak3.png


3) Go to Scripts tab.

Pagebreak4.png


4) Copy the following scripts and paste at bottom of the scripts.

Script template:


int a=0; private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
{

 a++;
 DevExpress.XtraReports.UI.DetailBand band = (DevExpress.XtraReports.UI.DetailBand)sender;
 if(a==10){
  a=0;
 band.PageBreak = PageBreak.AfterBand;
}else band.PageBreak = PageBreak.None;

}


Remark : The if(a==10) means 10 items per page, if you want 15 items per page just change the figure 10 to 15.


Pagebreak5.png


5) Back to Designer tab and click on InvoiceDetail, at Property Grid (at right panel) , scroll down and look for Behavior, expand the Scripts, for Before Print > Select OnBeforePrint.

Pagebreak6.png


6) After selected OnBeforePrint, system will switch to the Scripts tab. Now you may click on File > Save As.., fill in your report name and click on Save.

Pagebreak7.png


Pagebreak8.png


7) Try to preview with the newly designed report. Now every page has 10 items only.

Pagebreak9.png


Please refer to the following PDF file for an alternative way (Formatting Rule) to do page break.

Page break by using Formatting Rules


By : CK 190108, Lay Swan 190123, P190123



Go to menu

IconAcc20.PNG AutoCount Accounting 2.0


IconAcc188.PNG AutoCount Accounting 1.8 / 1.9
Wiki-Payroll.png AutoCount Payroll
Wiki-POS.PNG AutoCount POS
Wiki-AOTG.PNG AutoCount On The Go
Wiki-Accounting-Plugin.png AutoCount Accounting Plug-In Documentations