0
点赞
收藏
分享

微信扫一扫

Winform中使用FastReport的DesignReport时怎样给通过代码Table添加数据


场景


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

实现

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

记住Name 属性这里为Table1。

Winform中使用FastReport的DesignReport时怎样给通过代码Table添加数据_赋值

 

然后在按钮的点击事件里

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);
}

效果

Winform中使用FastReport的DesignReport时怎样给通过代码Table添加数据_赋值_02

 

注:

 

 

 

举报

相关推荐

0 条评论