zoukankan      html  css  js  c++  java
  • XtraReports 报表记录不满一页时填补空行

    Devexpress 版本:10.2.5

    先看实现效果

    当报表数据不满一页时,填补空行 

     

    当报表数据超过一页时,最后一页填补空行

     

     代码: 

    XtraReport rpt = new XtraReport();// 建立报表实例
    rpt.FillEmptySpace += new BandEventHandler(rpt_FillEmptySpace);//绑定填充空行的事件  

    对应的事件代码:

    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(00);
            }
            xrRow.Cells.Add(xrcell);
        }
    }
    用心写好每一篇文章
  • 相关阅读:
    Java时间转换的一个特性
    JS处理数据四舍五入
    DataReader分页性能测试
    Java通过cal.get(Calendar.MONTH)比真实月份少一个月
    sqlserver split函数
    一个CLR20r3 错误解决。
    Devexpress dll搜集
    正则表达式:小括号、中括号、大括号的区别
    Android手机有的不显示Toast
    保存页面数据的场所----Hidden、ViewState、ControlState
  • 原文地址:https://www.cnblogs.com/whlalhj/p/2013801.html
Copyright © 2011-2022 走看看