【问题标题】:How to Load rdlc report runtime如何加载 rdlc 报告运行时
【发布时间】:2015-05-13 00:47:39
【问题描述】:

我创建了 2 个报告 billa4.rdlc 和 billa5.rdlc,我想根据用户选择的组合框选项将其中一个报告加载到 reportviewer。 请帮帮我。 下面的代码正在加载 billa4.rdlc

Try
        Dim P2 As New ReportParameter("pbillnum", billnoprint)
        Me.DataTable1TableAdapter.Fill(Me.billdata.DataTable1, billnoprint)
        Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {P2})
        Me.ReportViewer1.SetDisplayMode(DisplayMode.PrintLayout)
        Me.ReportViewer1.ZoomMode = ZoomMode.FullPage
        Me.ReportViewer1.RefreshReport()

    Catch ex As Exception
        MsgBox("error")
    End Try

【问题讨论】:

    标签: vb.net rdlc


    【解决方案1】:

    你试过什么?不要直接从设计模式设置报表源,通过代码来实现。

    可能是这样的:

    if( combooption.SelectedValue = 0) Then
            Dim P2 As New ReportParameter("pbillnum", billnoprint)
            Me.DataTable1TableAdapter.Fill(Me.billdata.DataTable1, billnoprint)
            Me.ReportViewer1.ViewReport("billa4.rdlc")
            Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {P2})
            Me.ReportViewer1.SetDisplayMode(DisplayMode.PrintLayout)
            Me.ReportViewer1.ZoomMode = ZoomMode.FullPage
            Me.ReportViewer1.RefreshReport()
    else
            Dim P2 As New ReportParameter("pbillnum", billnoprint)
            Me.DataTable1TableAdapter.Fill(Me.billdata.DataTable1, billnoprint)
            Me.ReportViewer1.ViewReport("billa5.rdlc")
            Me.ReportViewer1.LocalReport.SetParameters(New ReportParameter() {P2})
            Me.ReportViewer1.SetDisplayMode(DisplayMode.PrintLayout)
            Me.ReportViewer1.ZoomMode = ZoomMode.FullPage
            Me.ReportViewer1.RefreshReport()
    End if
    

    【讨论】:

    • Dim P2 As New ReportParameter("pbillnum", billnoprint) Me.DataTable1TableAdapter.Fill(Me.billdata.DataTable1, billnoprint) Me.ReportViewer2.LocalReport.ReportPath("Bill.rdlc") Me. ReportViewer2.LocalReport.SetParameters(New ReportParameter() {P2}) Me.ReportViewer2.SetDisplayMode(DisplayMode.PrintLayout) Me.ReportViewer2.ZoomMode = ZoomMode.FullPage Me.ReportViewer2.RefreshReport() 我试过了,但没用
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多