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);
        }
    }
    用心写好每一篇文章
  • 相关阅读:
    GCC/gcc/g++/CC/cc区别
    C++静态库与动态库(转)
    Linux中find的使用(转)
    “《编程珠玑》(第2版)第2章”:B题(向量旋转)
    第一部分 DotNET与C#概述
    第一部分 二进制
    第一部分 计算机编程语言
    第一部分 计算机常识
    C# 泛型初探
    WPF 实现验证码功能
  • 原文地址:https://www.cnblogs.com/whlalhj/p/2013801.html
Copyright © 2011-2022 走看看