VS2010自带的报表(reportviewer)使用方法
2012-09-27 14:54
471 查看
本来想做一个水晶报表,突然发现VS2010没有自带的水晶报表,还要安装相应的插件。于是学了一下VS2010自带的报表。据说比水晶报表的加载速度快。下面详细介绍一下使用步骤:
1.先创建一个本地的数据库,右键单击你的项目-->选择【Add】--->New Item--->Local database.创建数据库后,添加一个数据表T_student,添加一些数据。
2.右键---->【Add】--->New Item--->Dataset(命名为information.xsd),把刚才创建的表T_student直接拖到information.xsd的设计界面上。
3.右键---->【Add】---->New Item---> Report(命名为report.rdlc),在report.rdlc的界面上右键---->【insert】---->【table】,此时会出现一个配置窗口,第一个【Name】填写你添加的dataset的名称(information),Data source选项选择information.
4.然后到winform界面。添加ReportViewer控件
5.在Form.cs中编写代码:
private void button2_Click(object sender, EventArgs e)
{
information ds1 = new information();
informationTableAdapters.table11TableAdapter ap = new informationTableAdapters.table11TableAdapter();
ap.Fill(ds1.table11);
DataTable dt1 = new DataTable();
dt1 = ds1.table11;
this.reportViewer1.Reset();
this.reportViewer1.LocalReport.DataSources.Clear();
this.reportViewer1.LocalReport.ReportPath = @"E:\test code\水晶报表\水晶报表\report1.rdlc";
ReportDataSource rds = new ReportDataSource("information", dt1);
//ReportDataSource数据源的第一个参数必须与你添加的dataset的名字相同
this.reportViewer1.LocalReport.DataSources.Add(rds);
//添加数据源
this.reportViewer1.ZoomMode = ZoomMode.Percent;
this.reportViewer1.RefreshReport();
}
1.先创建一个本地的数据库,右键单击你的项目-->选择【Add】--->New Item--->Local database.创建数据库后,添加一个数据表T_student,添加一些数据。
2.右键---->【Add】--->New Item--->Dataset(命名为information.xsd),把刚才创建的表T_student直接拖到information.xsd的设计界面上。
3.右键---->【Add】---->New Item---> Report(命名为report.rdlc),在report.rdlc的界面上右键---->【insert】---->【table】,此时会出现一个配置窗口,第一个【Name】填写你添加的dataset的名称(information),Data source选项选择information.
4.然后到winform界面。添加ReportViewer控件
5.在Form.cs中编写代码:
private void button2_Click(object sender, EventArgs e)
{
information ds1 = new information();
informationTableAdapters.table11TableAdapter ap = new informationTableAdapters.table11TableAdapter();
ap.Fill(ds1.table11);
DataTable dt1 = new DataTable();
dt1 = ds1.table11;
this.reportViewer1.Reset();
this.reportViewer1.LocalReport.DataSources.Clear();
this.reportViewer1.LocalReport.ReportPath = @"E:\test code\水晶报表\水晶报表\report1.rdlc";
ReportDataSource rds = new ReportDataSource("information", dt1);
//ReportDataSource数据源的第一个参数必须与你添加的dataset的名字相同
this.reportViewer1.LocalReport.DataSources.Add(rds);
//添加数据源
this.reportViewer1.ZoomMode = ZoomMode.Percent;
this.reportViewer1.RefreshReport();
}
相关文章推荐
- vs2010(中文版)自带报表的使用(二过程)
- vs 2008自带报表使用方法
- vs2010自带报表的使用
- vs2010(中文版)自带报表的使用(二过程)
- VS2010 使用RDLC报表 布置在XP系统中 汉字全成了乱码 的解决方法
- 在WPF中使用水晶报表for vs2010的方法
- WinForm VS2010自带报表使用心得整理
- VS2010 水晶报表的使用方法
- 在WPF中使用水晶报表for vs2010的方法
- 在WPF中使用水晶报表for vs2010的方法
- vs2010自带报表的使用(一用途)
- 在VS2010Winform项目中使用RDLC报表定义文件、ReportViewer控件生成本地报表
- vs2010自带sql2008数据库使用方法 添加管理界面
- vs2010(中文版)自带报表的使用(二过程)
- VS2010 中使用ReportViewer显示Reporting Services报表,部署注意
- VS2010 水晶报表的使用方法
- 在VS2010Winform项目中使用RDLC报表定义文件、ReportViewer控件生成本地报表
- 使用vs2010自带的数据库的方法
- 使用wordpress自带ajax方法
- vs2010使用openCV中的imread读不到图片问题的解决方法