How to open different rdlc in a single Report Viewer control?

0

What could be wrong with my code below?

Private Sub LocalReport(ByVal digito As Integer)

Dim relatorioCorrente = New Microsoft.Reporting.WinForms.ReportDataSource()

ReportViewer1.LocalReport.DataSources.Clear()
If (digito = 1) Then
    ReportViewer1.LocalReport.ReportEmbeddedResource = "ReportViewer.rpt1.rdlc"
    mcv_modbusTableAdapter.Fill(geradorxmlDS.mcv_modbus)
    relatorioCorrente.Name = "geradorxmlDS"
    relatorioCorrente.Value = mcv_malhaBindingSource
    ReportViewer1.LocalReport.DataSources.Add(relatorioCorrente)
ElseIf (digito = 2) Then
    ReportViewer1.LocalReport.ReportEmbeddedResource = "ReportViewer.rpt2.rdlc"
    mcv_modbusTableAdapter.Fill(geradorxmlDS.mcv_modbus)
    relatorioCorrente.Name = "geradorxmlDS"
    relatorioCorrente.Value = mcv_modbusBindingSource
    ReportViewer1.LocalReport.DataSources.Add(relatorioCorrente)
ElseIf (digito = 3) Then
    ReportViewer1.LocalReport.ReportEmbeddedResource = "ReportViewer.rpt3.rdlc"
    mcv_registroTableAdapter.Fill(geradorxmlDS.mcv_registro)
    relatorioCorrente.Name = "geradorxmlDS"
    relatorioCorrente.Value = mcv_registroBindingSource
    ReportViewer1.LocalReport.DataSources.Add(relatorioCorrente)
End If
ReportViewer1.RefreshReport()

End Sub

Could anyone give any suggestions? Thank you in advance for the help provided.

    
asked by anonymous 10.09.2015 / 15:13

1 answer

0

My issue has now been resolved. Follow the solution below for future reference.

    Public Class frmReport

Dim codRPT As Integer

Private Sub LocalReport (ByVal As Integer)

Dim reportCurrent = New Microsoft.Reporting.WinForms.ReportDataSource ()

If (digit = 1) Then mcv_malhaTableAdapter.Fill (generator xmlDS.mcv_malha) reportCorrent.Name="malhDS" reportCurrent.Value = generatorxmlDS.mcv_malha RV.LocalReport.DataSources.Clear () RV.LocalReport.DataSources.Add (RuntimeReport) RV.LocalReport.ReportEmbeddedResource="ReportViewer.rpt1.rdlc" ElseIf (digit = 2) Then mcv_modbusTableAdapter.Fill (generator xmlDS.mcv_modbus) reportCurrent.Name="modbDS" reportCurrent.Value = generatorxmlDS.mcv_modbus RV.LocalReport.DataSources.Clear () RV.LocalReport.DataSources.Add (RuntimeReport) RV.LocalReport.ReportEmbeddedResource="ReportViewer.rpt2.rdlc" ElseIf (digit = 3) Then mcv_registroTableAdapter.Fill (generatorxmlDS.mcv_registro) reportCurrent.Name="regiDS" reportCurrent.Value = generatorxmlDS.mcv_register RV.LocalReport.DataSources.Clear () RV.LocalReport.DataSources.Add (RuntimeReport) RV.LocalReport.ReportEmbeddedResource="ReportViewer.rpt3.rdlc" End If RV.RefreshReport ()

End Sub

Private Sub ComboBox1_SelectedIndexChanged_1 (sender As Object, and As EventArgs) Handles ComboBox1.SelectedIndexChanged

LocalReport (ComboBox1.SelectedItem.ToString)

End Sub

End Class

    
14.09.2015 / 14:13