I've got a form named frmReportViewer, containing a CrystalReportViewer named crvReportViewer.
frmReportViewer is an all-purpose form, displaying whatever Crystal Report I tell it to programmatically on a button click event from various forms.
Some sample code:
As you can see the hourglass cursor is turned on before the processing starts, and then in the "Finally" portion of Try..Catch, it's reset to the default.
When reports are smaller, they seem to appear in frmReportViewer almost immediately. However, on longer reports, the user is presented with a blank form as data loads.
Is there a way to determine when the data has finished loading into crvReportViewer? And perhaps delay showing frmReportViewer until this has happened? Or display an hourglass after frmReportViewer loads, until crvReportViewer is complete with data?
Thanks in advance.
Bryant Farley
"The Dude Abides
frmReportViewer is an all-purpose form, displaying whatever Crystal Report I tell it to programmatically on a button click event from various forms.
Some sample code:
Code:
Dim cur As Cursor = Nothing
Dim frm As New frmReportViewer
Dim crv As CrystalReportViewer = frm.crvReportViewer
Dim crpt As ReportDocument = New ReportDocument
Try
Dim intCounter As Integer = 0
Dim strAccounts As String = Nothing
Dim strCompany As String = Nothing
Dim strReportName As String = "myreport.rpt"
cur = Me.Cursor
Me.Cursor = Cursors.WaitCursor
' Load report file
crpt.Load(strReportName)
Dim ctblCurrent As Table
Dim tlogCurrent As TableLogOnInfo
' Supply logon info
For Each ctblCurrent In crpt.Database.Tables
tlogCurrent = ctblCurrent.LogOnInfo
With tlogCurrent.ConnectionInfo
.ServerName = My.Settings.JamisSqlServerName
.UserID = <username>
.Password = <password>
.DatabaseName = <dbname>
End With
ctblCurrent.ApplyLogOnInfo(tlogCurrent)
Next ctblCurrent
Dim crParameterDiscreteValue As ParameterDiscreteValue
Dim crParameterFieldDefinitions As ParameterFieldDefinitions
Dim crParameterFieldLocation As ParameterFieldDefinition
Dim crParameterValues As ParameterValues
' Parameter 1: BeginningDate
crParameterFieldDefinitions = crpt.DataDefinition.ParameterFields
crParameterFieldLocation = crParameterFieldDefinitions.Item("BeginningDate")
crParameterValues = crParameterFieldLocation.CurrentValues
crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
crParameterDiscreteValue.Value = Format(dtpStartDate.Value, "yyyyMMdd")
crParameterValues.Add(crParameterDiscreteValue)
crParameterFieldLocation.ApplyCurrentValues(crParameterValues)
' Set viewer's source to this report
crv.ReportSource = crpt
frm.Show()
Catch ex As Exception
MessageBox.Show("Error: " + ex.ToString(), Me.Name & ": btnCreateReport_Click", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation)
Finally
Me.Cursor = cur
End Try
As you can see the hourglass cursor is turned on before the processing starts, and then in the "Finally" portion of Try..Catch, it's reset to the default.
When reports are smaller, they seem to appear in frmReportViewer almost immediately. However, on longer reports, the user is presented with a blank form as data loads.
Is there a way to determine when the data has finished loading into crvReportViewer? And perhaps delay showing frmReportViewer until this has happened? Or display an hourglass after frmReportViewer loads, until crvReportViewer is complete with data?
Thanks in advance.
Bryant Farley
"The Dude Abides