locked
when rdlc report load then invoke or begininvoke cannot be called on a control until the window handle has been created error occure RRS feed

  • Question

  • I have form (rdlcreport.vb) to show monthly report, when the user click show button that time data fill in tmp table and bind to report. its open first time,but try to open multiple time. Then error occure.

    The problem is that when open report form one by one (invoke one,view the report,close the report window, and invoke again), the application crash when the report is rendering (the window show, and the green circular progress bar begin to show) with the error "Invoke or BeginInvoke cannot be called on a control until the window handle has been created."

    my code :-

     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'TODO: This line of code loads data into the 'FlowGaugeRetrivalAccessDBDataSet.temprpt' table. You can move, or remove it, as needed.
            Me.ReportViewer1.Clear()
            Me.temprptTableAdapter.Fill(Me.FlowGaugeRetrivalAccessDBDataSet.temprpt)
            If Not Me.IsHandleCreated Then
                Me.CreateHandle()
            End If
         
            Call DailyReport()

        End Sub
        Private Sub DailyReport()
            If Not Me.IsHandleCreated Then
                Me.CreateHandle()
            End If
            Try
                'Dim report2 As LocalReport = New LocalReport()
                'report2.ReportPath = "..\..\Report2.rdlc"
                Dim ds_River = New DataSet
                ds_River.clear()
                If strPara2 = "1" Then
                    da_newrptdetails = New OleDbDataAdapter("select * from temprpt where ProjectId='" & strStation & "' and ProjectName='" & strstation2 & "' and StationId='" & strStation1 & "'and GaugeType='" & gaugetype & "' and GaugeName='" & gaugename & "'", cn)
                    ds_newrptdetails.Clear()
                Else
                    da_newrptdetails = New OleDbDataAdapter("select * from temprpt where ProjectId='" & strStation3 & "' and ProjectName='" & strstation4 & "' ", cn)
                    ds_newrptdetails.Clear()
                End If
                da_newrptdetails.Fill(ds_River, "temprpt")

                If ds_River.Tables(0).Rows.Count = 0 Then
                    MessageBox.Show("No records to display")
                    Exit Sub
                End If

                Dim report_name As New ReportParameter("Report_name", "Flow Gauge Data retrival for " & strstation2)
                Dim report_mont As New ReportParameter("month", "Month:- " + monthname1)
                Dim reprot_type, station1 As New ReportParameter
                Dim station As String
                If strPara2 = 1 Then
                    station = gaugename
                    Dim report As String = "Report Type:- Single Flow Meter "
                    reprot_type = New ReportParameter("report_type", report)
                    station1 = New ReportParameter("stationid", "Station Name:-" + station)
                    Me.ReportViewer1.SetDisplayMode(DisplayMode.PrintLayout)
                    Me.ReportViewer1.ZoomMode = ZoomMode.Percent
                Else
                    station = gaugename
                    Dim report As String = "Report Type:- All Flow Meter "
                    reprot_type = New ReportParameter("report_type", report)
                    station1 = New ReportParameter("stationid", "Station Name:-" + station)
                    'Dim pg As New System.Drawing.Printing.PageSettings()
                    'pg.Margins.Top = 0
                    'pg.Margins.Bottom = 0
                    'pg.Margins.Left = 0
                    'pg.Margins.Right = 0
                    'Dim Size As New System.Drawing.Printing.PaperSize
                    'Size = New Printing.PaperSize()
                    'Size.RawKind = 8
                    'pg.PaperSize = Size
                    'ReportViewer.SetPageSettings(pg)
                 End If
               ReportViewer1.LocalReport.SetParameters(New ReportParameter() {report_name, reprot_type, report_mont, station1})
                Me.ReportViewer1.RefreshReport()
            Catch ex As Exception
            Finally
                cn.Close()
            End Try
        End Sub

    Monday, December 24, 2012 11:10 AM

Answers

All replies