C#子报表功能
2016-02-22 11:36
507 查看
调用的是reportViewer1.LocalReport.SubreportProcessing
下面是实现步骤
1.主RepMain.rdlc配置
2.子RepMainChild.rdlc配置
3,主窗体绑定RepMain.rdlc,代码如下
下面是实现步骤
1.主RepMain.rdlc配置
2.子RepMainChild.rdlc配置
3,主窗体绑定RepMain.rdlc,代码如下
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Microsoft.Reporting.WinForms; namespace 钻取子报表 { public partial class Form2 : Form { public Form2() { InitializeComponent(); } private void Form2_Load(object sender, EventArgs e) { this.LoadReport(); } private void button1_Click(object sender, EventArgs e) { this.LoadReport(); } protected void LoadReport() { string depid = this.textBox1.Text.Trim().ToString(); string sql = @"select depid,depname,parents from dep where 1=1"; if (depid.Length>0) { sql += " and depid='" + depid + "'"; } DataTable dt = DBUtil.getDataTable(sql); ReportDataSource rds = new ReportDataSource("DataSet1", dt); this.reportViewer1.LocalReport.SubreportProcessing += LocalReport_SubreportProcessing; this.reportViewer1.LocalReport.DataSources.Clear(); this.reportViewer1.LocalReport.DataSources.Add(rds); this.reportViewer1.LocalReport.Refresh(); this.reportViewer1.RefreshReport(); } void LocalReport_SubreportProcessing(object sender, SubreportProcessingEventArgs e) { string depid = this.textBox1.Text.Trim().ToString(); string sql = @"select userid,username,depid from users where 1=1"; if (depid.Length > 0) { sql += " and depid='" + depid + "'"; } DataTable dt = DBUtil.getDataTable(sql); ReportDataSource rds = new ReportDataSource("DataSet1", dt); e.DataSources.Clear(); e.DataSources.Add(rds); } } }
相关文章推荐
- C# partial关键字说明
- CSharpGL(15)用GLSL渲染2种类型的文字
- C#Winform钻取子报表功能
- C# 10进制和64进制相互转换
- C#中怎样在Button控件上添加提示语,让鼠标经过按钮时显示提示信息!
- C#Hashtable键值对集合
- C# 定时器运用
- 【C#】添加鼠标管轮事件
- 【C#】 开机启动/取消开机启动
- C#编程 线程同步
- c# using三种用法
- C#中XML与对象之间的序列化、反序列化
- 讲解C#设计模式编程中享元模式的运用
- C#中窗体渐显渐隐
- C#事件快捷设置
- 详解C#中的反射
- c#对字符串的各种操作
- c#中的数据类型简介(枚举)
- C#中HashTable的用法
- C#遍历DataSet中数据的几种方法总结