
具体 *** 作是先拖动reportviewer控件到神御窗体,点右上角的设计新报表,数据源里面选择“数据库",歼如输入查询条件,然后一直下一步就可以了
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()
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)