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

Asked

Viewed 150 times

0

What could be wrong in 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

Would anyone care to make any suggestions? Thanks in advance for the help provided.

1 answer

0


My problem has already been solved. Follow solution below for future consultation.

    Public Class frmReport

Dim codRPT As Integer

Private Sub Localreport(Byval digito As Integer)

Dim reportCurrent = New Microsoft.Reporting.Winforms.Reportdatasource()

If (type = 1) Then mcv_malhaTableAdapter.Fill(generatorxmlDS.mcv_mesh) report.Name = "malhDS" report.Value = generatorxmlDS.mcv_mesh RV.LocalReport.Datasources.Clear() RV.LocalReport.Datasources.Add(reportCurrent) RV.LocalReport.Reportembeddedresource = "Reportviewer.rpt1.rdlc" Elseif (digit = 2) Then mcv_modbusTableAdapter.Fill(generatorxmlDS.mcv_modbus) report.Name = "modbDS" report.Value = generatorxmlDS.mcv_modbus RV.LocalReport.Datasources.Clear() RV.LocalReport.Datasources.Add(reportCurrent) RV.LocalReport.Reportembeddedresource = "Reportviewer.rpt2.rdlc" Elseif (digit = 3) Then mcv_registrationTableAdapter.Fill(generatorxmlDS.mcv_record) report.Name = "regiDS" report.Value = generatorxmlDS.mcv_record RV.LocalReport.Datasources.Clear() RV.LocalReport.Datasources.Add(reportCurrent) 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

  • Format the code, horrible like this

Browser other questions tagged

You are not signed in. Login or sign up in order to post.