设为首页 加入收藏

TOP

Winform中使用FastReport的DesignReport时怎样给通过代码Table添加数据
2019-09-19 11:09:59 】 浏览:32
Tags:Winform 使用 FastReport DesignReport 怎样 通过 代码 Table 添加 数据

场景

FastReport安装包下载、安装、去除使用限制以及工具箱中添加控件:

https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/100893794

Winform中使用FastReport实现简单的自定义PDF导出:

https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/100920681

在上面的基础上,在设计模板时添加一个Table,然后在点击打印预览页面,对Table进行赋值。

实现

打开Design Report 界面,在左边菜单栏拖拽一个Table控件,然后改为一行两列,具体根据自己需求。

记住Name 属性这里为Table1。

 

 

然后在按钮的点击事件里

var table1 = report1.FindObject("Table1") as TableObject ;

            if (table1 != null)
            {
               
                //设置表格的边框颜色
                table1.Border.Color = Color.Red;
                //设置表格的border全显示
                table1.Border.Lines = BorderLines.All;
                //新建一行
                TableRow row1 = new TableRow();
                //新建Cell1
                TableCell cell1 = new TableCell();
                //Cell1赋值
                cell1.Text = "公众号:";
                //新建Cell2
                TableCell cell2 = new TableCell();
                //设置Cell的边框属性
                cell2.Border.Color = Color.Black;
                cell2.Border.Lines = BorderLines.All;
                //Cell2赋值
                cell2.Text = "霸道的程序猿";
                //讲Cell添加到Row
                row1.AddChild(cell1);
                row1.AddChild(cell2);
                //将ROw添加到table
                table1.Rows.Add(row1);
            }

 

效果

 

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇在 ABP vNext 中编写仓储单元测试.. 下一篇Lambda表达式

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目