Fill blank lines when the XtraReports report record is less than one page

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.