FastReport Table的使用
如果Table在DataBind中,则会自动重复遍历row,并重复打印table
如果DataBind中的table,包含表头/表尾等,如果每行数据都打印,显然不是想要的结果
解决方案,设置DataBind的datasource为none,在table的ManualBuild事件中自己手动写代码遍历打印table指定的行
private void Table1_ManualBuild(object sender, EventArgs e) { // 获取数据源 DataSourceBase mainData=Report.GetDataSource("main"); DataSourceBase rowData = Report.GetDataSource("detail"); // 添加关系映射 Relation dataRelation=new Relation(); dataRelation.ParentDataSource= mainData; dataRelation.ChildDataSource= rowData; dataRelation.ParentColumns=new String[]{"docNo"}; dataRelation.ChildColumns=new String[]{"docNo"}; Report.Dictionary.AddChild(dataRelation); Parameter pIndex=Report.GetParameter("rowIndex"); // 初始化数据源 rowData.Init(mainData); // 打印第一行 table_detail.PrintRow(0); // PrintRow方法后必须调用 PrintColumn/PrintColumns 以打印行中的列 table_detail.PrintColumns(); int index=1; // 遍历打印数据 while(rowData.HasMoreRows) { pIndex.Value=index; table_detail.PrintRow(1); table_detail.PrintColumns(); index++; // 移动到下一行数据 rowData.Next(); } }
GarsonZhang www.yesdotnet.com
版权声明:本文为YES开发框架网发布内容,转载请附上原文出处连接
post YES开发框架