dev处理空白页面增加空白行

在这里插入图片描述

在这里插入图片描述

在Fill Empty Space的事件中,把下面的脚本拷进去,再根据需要进行微调,例如边框颜色等:

private void XtraReport_FillEmptySpace(object sender, DevExpress.XtraReports.UI.BandEventArgs e) {

	XRTable table = this.table1; //根据要显示数据的表格获取相关的属性值
	int pubheight = table.Rows[table.Rows.Count - 1].Height; //默认为设计时的//单元行的高度,如需调整高度,自行设置数值。如:int pubheight = 30;
	XRTable xrTable = new XRTable();   //新建填充的空白表
      xrTable.Size = new Size(table.Width, e.Band.Height-1);   //设置添加空行表的大//小,注意要和上面显示数据的表的宽度一样。
      xrTable.BorderWidth = table.BorderWidth; //根据显示数据的表设置边框的宽度
      xrTable.Location = table.Location;
	//xrTable.BorderColor = table.BorderColor;
	xrTable.BorderColor = Color.LightGray;
	int SpaceRowCount = e.Band.Height / pubheight;
	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, pubheight);

                xrRow[i].Location = new Point(table.Location.X, i * pubheight);
                //设置一行的边框
                xrRow[i].Borders = ((DevExpress.XtraPrinting.BorderSide)(((DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right)

                         | DevExpress.XtraPrinting.BorderSide.Bottom)));

                xrRow[i].BorderWidth = 1;
                //xrRow[i].BorderColor = table.Rows[table.Rows.Count - 1].BorderColor;  //设置边框颜色
                xrRow[i].BorderColor = Color.LightGray;
               CreateCellArray(xrRow[i],table,pubheight);

            }

            xrTable.Rows.AddRange(xrRow);
            e.Band.Controls.Add(xrTable);
        }
}
/// 
/// 创建空白行的Cell
///在XRTableRow中添加单元格
/// 
/// 
private void CreateCellArray(XRTableRow xrRow,XRTable table,int pubheight)
{
	XRTableRow row = table.Rows[table.Rows.Count - 1]; //获取最后一行
	int Xmargin = 0;
	for (int i = 0; i < row.Cells.Count; i++)
	{
		XRTableCell xrcell = new XRTableCell();
		xrcell.BorderWidth = 1;
		//下面是设置单元的边框,根据实际情况设置
		xrcell.Borders = (DevExpress.XtraPrinting.BorderSide)((DevExpress.XtraPrinting.BorderSide)(( DevExpress.XtraPrinting.BorderSide.Left | DevExpress.XtraPrinting.BorderSide.Right | DevExpress.XtraPrinting.BorderSide.Bottom)));
		//xrcell.Width = Convert.ToInt32(row.Cells[i].WidthF);
		xrcell.WidthF = row.Cells[i].WidthF;
		xrcell.BackColor = row.Cells[i].BackColor;
		//xrcell.BorderColor = row.Cells[i].BorderColor;
		xrcell.Height = pubheight;
			if (i != 0)
			{
				xrcell.Location = new Point(Convert.ToInt32(Xmargin + row.Cells[i].WidthF), 0);
			}
			else
			{
				xrcell.Location = new Point(0, 0);
			}
		xrRow.Cells.Add(xrcell);
	}
}

效果如下图:

在这里插入图片描述

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值