一个reportviewer控件怎么一次绑定多个rdlc文件

2024-12-12 03:38:04
推荐回答(1个)
回答1:

可以,在界面加载的时候做个判断,给你个示例:

public Form2(System.Data.DataTable dtData)
        {
            InitializeComponent();
            if (this.comboBox1.Text == "月份")
            {
                this.reportViewer1.LocalReport.ReportPath = @"..\..\Report1.rdlc";
                this.reportViewer1.LocalReport.DataSources.Clear();
                this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dtData));
            }
            else if (this.comboBox1.Text == "星期"察桥改)
            {
    消虚            this.reportViewer1.LocalReport.ReportPath = @"..\..\Report2.rdlc";
                this.reportViewer1.LocalReport.DataSources.Clear();
                this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dtData));
            }
     败判   }

选择哪个选项,就显示哪个rdlc