I've been reading this forum for a while now and found it to be very good at giving advice. I'm hoping someone can tell me where I'm going wrong!
I have a "MicrosoftReportViewer" on a form and a Combo box that lists the available reports (which will end up being dynamic in the end).
When the use selects an item from the list, the system loads up the correct report (populating any datasets needed) and then displaying it.
Thing is, I can't get the viewer to change the displayed report, it just refreshes the first loaded report.
As you can see from the code below, there are two reports set up. I can get either one to be displayed if you select it first, sadly you're then stuck with that one!
Currently they both use the same datasouce, so no need to mess about with that.
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged Me.viw_ShowAllRepairsTableAdapter.Fill(Me.RepairsSystemDataSet.viw_ShowAllRepairs) Select Case CType(ComboBox1.SelectedItem, String).ToLower Case "rpttest" rptView.LocalReport.ReportPath = Path.Combine(Application.StartupPath, "rptTest.rdlc") Case "rptallrepairs" rptView.LocalReport.ReportPath = Path.Combine(Application.StartupPath, "rptAllRepairs.rdlc") End Select rptView.LocalReport.Refresh() rptView.RefreshReport() End Sub
I've tried using the "rptView.LocalReport.ReportEmbeddedResource" property and I get the same results.
Tried the following as well:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged Me.viw_ShowAllRepairsTableAdapter.Fill(Me.RepairsSystemDataSet.viw_ShowAllRepairs) Dim strFile As String = "" Select Case CType(ComboBox1.SelectedItem, String).ToLower Case "rpttest" strFile = Path.Combine(Application.StartupPath, "rptTest.rdlc") Case "rptallrepairs" strFile = Path.Combine(Application.StartupPath, "rptAllRepairs.rdlc") End Select If strFile<>"" then Dim strIn As New StreamReader(strFile) rptView.LocalReport.LoadReportDefinition(strIn) rptView.LocalReport.Refresh() rptView.RefreshReport() strIn.Close() strIn = Nothing End If End Sub
This just loads up the report that the viewer has set as the default, reguardless of the report selected!
What am I missing? There should be a way to change the report being viewed and I don't really want to be having multiple viewers just to house multiple reports
Thanks in advance.
Ben
-----

New Topic/Question
Reply




MultiQuote



|