Previewing an RDLC report

Dracarnion

Member
Joined
Apr 10, 2007
Messages
11
Programming Experience
5-10
Hello -

I have a program that creates an RDLC report and then allows the user to print it. Now I would like to have the functionality to show a print preview before it is printed.

The problem is, the printpreviewdialog and printpreviewcontrol controls can only take a document as a source, and not a Report.

How can I preview this report as a document?

Thanks in advance.
 
VB.NET:
        ' Set up ToFax report
        Dim ToFaxReport As New Microsoft.Reporting.WinForms.LocalReport
        ToFaxReport.ExecuteReportInCurrentAppDomain(System.Reflection.Assembly.GetCallingAssembly.Evidence)
        ToFaxReport.AddTrustedCodeModuleInCurrentAppDomain(GetType(FNet.slotID).AssemblyQualifiedName)
        ToFaxReport.ReportEmbeddedResource = "Edit_Purchase_Order.ToFax PO Report.rdlc"
        ' Filter results, removing from ToFax report any rows with alerts: "Item Size Upgrade", "Broken-Up Set", or "Gift Set Upgrade"
        POLineBindingSource.DataSource = New SuperCollection(Of POLine)
        CType(POLineBindingSource.DataSource, SuperCollection(Of POLine)).ApplySort(TypeDescriptor.GetProperties(GetType(POLine)).Find("itemName", True), _
            ListSortDirection.Ascending)
        CType(POLineBindingSource.DataSource, SuperCollection(Of POLine)).AddRange(Business.GetFilteredItemsDataSource(cmboPO.Text, cmboSupplier.SelectedValue))
        ToFaxReport.DataSources.Add(New Microsoft.Reporting.WinForms.ReportDataSource("Edit_Purchase_Order_POLine", POLineBindingSource.DataSource))

        ' Set up report parameters for both reports
        Dim ReportParameters As New SuperCollection(Of Microsoft.Reporting.WinForms.ReportParameter)

        ReportParameters.Add(New Microsoft.Reporting.WinForms.ReportParameter("poID", Me.cmboPO.Text))
        ReportParameters.Add(New Microsoft.Reporting.WinForms.ReportParameter("poDate", Business.GetPODate(Me.cmboPO.Text)))
        ReportParameters.Add(New Microsoft.Reporting.WinForms.ReportParameter("supplierID", Me.cmboSupplier.SelectedValue.ToString))

        Dim dt As DataTable = Business.GetSupplierInfo(Me.cmboSupplier.SelectedValue)
        With dt.Rows(0)
            ReportParameters.Add(New Microsoft.Reporting.WinForms.ReportParameter("supplierName", .Item("supplierName").ToString))
            ReportParameters.Add(New Microsoft.Reporting.WinForms.ReportParameter("supplierAddress", .Item("address").ToString))
            ReportParameters.Add(New Microsoft.Reporting.WinForms.ReportParameter("supplierCity", .Item("city").ToString))
            ReportParameters.Add(New Microsoft.Reporting.WinForms.ReportParameter("supplierState", .Item("state").ToString))
            ReportParameters.Add(New Microsoft.Reporting.WinForms.ReportParameter("supplierZip", .Item("zip").ToString))
            ReportParameters.Add(New Microsoft.Reporting.WinForms.ReportParameter("supplierFax", .Item("faxNumber").ToString))
        End With

        ReportParameters.Add(New Microsoft.Reporting.WinForms.ReportParameter("withMatchData", Me.chkMatchData.Checked))

        ' Add parameters to reports
        ToFaxReport.SetParameters(ReportParameters)


' Print preview
        If Me.chkPrintPreview.Checked Then
            PrintPreview.Show()
        End If

''' WHEN I TRY TO SHOW THE PREVIEW HERE, I gET THE PARAMETER X IS MISSING A VALUE.. BUT WHEN I PRINT THE REPORT, ALL THE VALUES GO THROUGH NO PROBLEM
        
' Print ToFax report
        Dim ToFaxReportPrinter As New FNetReports.RDLCPrinter(ToFaxReport)
        ToFaxReportPrinter.Print()
THANKS
 
Back
Top