Devexpress version: 10.2.5
First look at the Implementation Effect
Empty rows are filled when report data falls below one page
When the report data exceeds one page, the last page fills in blank lines.
Code:
XtraReport rpt = new XtraReport (); // create a report instance
Rpt. FillEmptySpace + = new BandEventHandler (rpt_FillEmptySpace); // bind the event of filling empty rows
Corresponding Event code:
Void rpt_FillEmptySpace (object sender, BandEventArgs e)
{
XRTable table = tableDetail; // Template Detail Band XRTable
Int iheight = table. Rows [table. Rows. Count-1]. Height;
XRTable xrTable = new XRTable ();
XrTable. Size = new Size (table. Width, e. Band. Height-1 );
XrTable. BorderWidth = table. BorderWidth;
XrTable. Location = table. Location;
XrTable. BackColor = table. BackColor;
Int SpaceRowCount = e. Band. Height/iheight;
XRTableRow [] xrRow = new XRTableRow [SpaceRowCount];
If (SpaceRowCount> 0)
{
For (int I = 0; I <SpaceRowCount; I ++)
{
Xrrow [I] = new xrtablerow ();
Xrrow [I]. size = new size (table. Width, iheight );
Xrrow [I]. Location = new point (table. Location. X, I * iheight );
Xrrow [I]. Borders = (devexpress. xtraprinting. borderside) (borderside. Left | borderside. Right) | borderside. Bottom );
Xrrow [I]. borderwidth = 1;
Xrrow [I]. bordercolor = table. Rows [Table. Rows. Count-1]. bordercolor;
// Createcell
Xrtablerow ROW = table. Rows [Table. Rows. Count-1];
Createcellarray (xrrow [I], row );
}
Xrtable. Rows. addrange (xrrow );
E. Band. Controls. Add (xrtable );
}
}
/// <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. Bottom );
Xrcell. WidthF = xrRowTemplate. Cells [I]. WidthF;
Xrcell. BackColor = xrRowTemplate. Cells [I]. BackColor;
Xrcell. Height = xrRowTemplate. Height;
If (I! = 0)
{
Xrcell. Location = new Point (Convert. ToInt32 (Xmargin + xrRowTemplate. Cells [I]. WidthF), 0 );
}
Else
{
Xrcell. Location = new Point (0, 0 );
}
XrRow. Cells. Add (xrcell );
}
}