In the detail event:
Int I = 0;
Private void onbeforeprint (Object sender, system. Drawing. Printing. printeventargs e ){
// Control the number of items displayed on each page
If (I! = 0 & I % 8 = 0) // 8 entries per page
{
Detail. pagebreak = devexpress. xtrareports. UI. pagebreak. beforeband;
}
Else
{
Detail. pagebreak = devexpress. xtrareports. UI. pagebreak. None;
}
I ++;
}
In the table event:
Private void onbeforeprint (Object sender, system. Drawing. Printing. printeventargs e ){
//////////////////////////////////////// ///// // Replace the dataset "storagebillmatitem"
If (I = (system. Data. dataset) (xtrareport1.datasource). Tables ["storagebillmatitem"]. Rows. Count)
{
Xrtable table = xrtable2; // template detail band xrtable
Int iheight = table. Rows [Table. Rows. Count-1]. height;
Int spacerowcount = 8-(I) % 8;
Xrtablerow [] xrrow = new xrtablerow [spacerowcount];
For (int K = 0; k <spacerowcount; k ++)
{
Xrrow [k] = new xrtablerow ();
Xrrow [K]. size = new size (table. Width, iheight );
Xrrow [K]. Location = new point (table. Location. X, K * iheight );
Xrrow [K]. Borders = (devexpress. xtraprinting. borderside) (borderside. Left | borderside. Right) | borderside. Top );
Xrrow [K]. borderwidth = 1;
Xrrow [K]. bordercolor = table. Rows [Table. Rows. Count-1]. bordercolor;
// Createcell
Xrtablerow ROW = table. Rows [Table. Rows. Count-1];
Createcellarray (xrrow [K], row );
}
Xrtable2.rows. addrange (xrrow );
}
}
/// <Summary>
/// Createcell
/// </Summary>
/// <Param name = "xrrow"> current row </param>
/// <Param name = "xrrowtemplate"> row template </param>
Private void createcellarray (xrtablerow xrrow, xrtablerow xrrowtemplate)
{
Int xmargin = 0;
For (INT I = 0; I <xrrowtemplate. cells. Count; I ++)
{
Xrtablecell xrcell = new xrtablecell ();
Xrcell. borderwidth = 1;
Xrcell. Borders = (devexpress. xtraprinting. borderside) (borderside. Left | borderside. Right) | borderside. Top );
Xrcell. width = xrrowtemplate. cells [I]. width;
Xrcell. backcolor = xrrowtemplate. cells [I]. backcolor;
Xrcell. Height = xrrowtemplate. height;
If (I! = 0)
{
Xrcell. Location = new point (convert. toint32 (xmargin + xrrowtemplate. cells [I]. width), 0 );
}
Else
{
Xrcell. Location = new point (0, 0 );
}
Xrrow. cells. Add (xrcell );
}
}