2015-05-12 79 views
0

我創建了2個報表billa4.rdlc和billa5.rdlc,我想根據用戶選擇的組合框選項將報表加載到報表查看器。 請幫我這個。 下面的代碼加載billa4.rdlc如何加載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 

回答

0

你嘗試過什麼?不要直接從設計模式設置報告源,請使用代碼完成。

也許是這樣的:

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 
+0

昏暗的P2作爲新ReportParameter( 「pbillnum」,billnoprint) Me.DataTable1TableAdapter.Fill(Me.billdata.DataTable1,billnoprint) Me.ReportViewer2.LocalReport.ReportPath ( 「Bill.rdlc」) Me.ReportViewer2.LocalReport.SetParameters(新澤西ReportParameter(){P2}) Me.ReportViewer2.SetDisplayMode(DisplayMode.PrintLayout) Me.ReportViewer2.ZoomMode = ZoomMode.FullPage Me.ReportViewer2 .RefreshReport() 我試過了不工作 –