码迷,mamicode.com
首页 > 其他好文 > 详细

XtraReport 添加空行的办法,很详细

时间:2014-12-23 23:57:35      阅读:388      评论:0      收藏:0      [点我收藏+]

标签:

这两天为了做报表,研究了一下XtraReport 。为了添加空行,想了很多办法。其中如果有分组时,网上给出的办法就会失败。
现将经验公布一下,希望各位都能少走弯路。

1.加入自定义函数CreateCellArray,用于创建空行。
2.生成报表的 FillEmptySpace 事件,填写如下代码。
3.tableDetail 是指细节 区带
4.****注意,如果有分组,必须将分组PrintAtBottom设置为true,就是将其下沉。

 
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.WidthF;
    xrcell.BackColor = xrRowTemplate.Cells.BackColor;
    xrcell.Height = xrRowTemplate.Height;
    if (i != 0)
    {
     xrcell.Location = new Point(Convert.ToInt32(Xmargin + xrRowTemplate.Cells.WidthF), 0);
    }
    else
    {
     xrcell.Location = new Point(0, 0);
    }
    xrRow.Cells.Add(xrcell);
   }
  }
  private void XR_HT_RT_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 = new XRTableRow();
     xrRow.Size = new Size(table.Width, iheight);
     xrRow.Location = new Point(table.Location.X, i * iheight);
     xrRow.Borders = (DevExpress.XtraPrinting.BorderSide)((BorderSide.Left | BorderSide.Right) | BorderSide.Bottom);
     xrRow.BorderWidth = 1;
     xrRow.BorderColor = table.Rows[table.Rows.Count - 1].BorderColor;
     //CreateCell
     XRTableRow row = table.Rows[table.Rows.Count - 1];
     CreateCellArray(xrRow, row);
    }
    xrTable.Rows.AddRange(xrRow);
    e.Band.Controls.Add(xrTable);
   }
  }

  

XtraReport 添加空行的办法,很详细

标签:

原文地址:http://www.cnblogs.com/ddlzq/p/4181393.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!