当前位置:编程学习 > C#/ASP.NET >>

C# Winform ReportView绑定数据

.net frame work 3.5 ReportView
1.建立rdlc文件,设计UI,绑定字段.新建一个dataset做数据源,主要是数据是临时的不需要持久化.
2.建立winform页面,拉一个MicrosoftreportViewer,选择一个新建的*.rdlc文件报表.
3.数据绑定,就是推拉模型,绑定报表要呈现的数据字段,绑定数据源
绑定代码:
reportViewer1.LocalReport.DataSources.Clear();
this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("dsNotice_Notice",
data.Notice));
this.reportViewer1.LocalReport.DataSources.Add(new Microsoft.Reporting.WinForms.ReportDataSource("dsNotice_Details",
data.Details));
this.reportViewer1.RefreshReport();
数据源名称:集合_表 dataset_table,如:dsNotice_Notice.
数据源的值:表对象.
多张表就add多次.
每次绑定前最好先清空下datasources.
打印:报表宽大于高默认横向打印,反之为纵向打印。

补充:软件开发 , C# ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,