?
Solved

Progress bar for Crystal Reports

Posted on 2007-03-19
10
Medium Priority
?
4,268 Views
Last Modified: 2013-11-07
I was wondering if anyone had any ideas on how to put a progress bar on the screen when a crystal report is generating.  I have tried creating a form with a progress bar on it, but, the report takes focus and there is no event to close the form as far as I can tell.  Some of our users are quite click-happy when nothing is happening on the screen, which there are some reports that take a while to run.

Thanks for your help
0
Comment
Question by:abbarnes
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +1
10 Comments
 
LVL 101

Accepted Solution

by:
mlmcc earned 1000 total points
ID: 18753582
As far as I know there is no way to do it.  I don't think Crystal provides any informationwhile it is generating the report that you could use to update a progress bar.

mlmcc
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 18753593
One thing you could try would be to generate the report in the background then display it.  Not sure if that can be done in .Net.

What version of Crystal?

mlmcc
0
 
LVL 23

Assisted Solution

by:Ido Millet
Ido Millet earned 1000 total points
ID: 18756302
It's true that Crystal doesn't expose progress information. In my viewer application, I show a rotating "Loading, Please Wait..." picture while the report is loading.  You can use the same approach.  Just keep testing the IsBusy property of CRViewer.

hth,
- Ido
0
Basic Security of Your VPC

So, you’ve got this shiny new VPC and a fancy new application configured on your EC2 servers ready to go. This application is only accessible from your computer, which is great for security, but you need your users to be able to access it! So, what’s the easiest way to do this?

 

Author Comment

by:abbarnes
ID: 18759611
mlmcc - We are using Crystal for .Net 2.0 in Visual Studio 2005.  

IdoMillet - I don't see an "IsBusy" property of the viewer.  

If I could just put something in front of the Crystal Viewer for a few seconds, it would be fine - it seems to take focus no matter what.  Here is a snippet of code, I was trying to run the progress form in a different thread to see if it made a difference:

......
Dim th As Thread = New Thread(AddressOf ShowProgress)
        th.Start()
     
        fr.oRpt = oRpt
        fr.ShowDialog()
        fr.Visible = False
...........

    Private Sub ShowProgress()
        If Not fg Is Nothing Then
            If Not fg.IsDisposed Then
                fg.BringToFront() : fg.Show()
            Else
                fg = New frmGenerate : fg.Show()
            End If
        Else
            fg = New frmGenerate : fg.Show()
        End If
    End Sub

Public Class frmViewReport
    Public oRpt As CrystalDecisions.CrystalReports.Engine.ReportDocument
     Private Sub frmViewReport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        crv1.ReportSource = oRpt
    End Sub
End Class
0
 
LVL 23

Expert Comment

by:Ido Millet
ID: 18759738
At least with the RDC, the code is

While CRViewer1.IsBusy
          ...

0
 

Author Comment

by:abbarnes
ID: 18764172
The only options that I see for the crystal report viewer are IsAccessible and IsDisposed.  IdoMillet are you using the crystal viewer that comes with VS 2005?
0
 
LVL 23

Expert Comment

by:Ido Millet
ID: 18764279
No, I'm using the RDC.  I assume IsDisposed is the equivalent call in VS 2005.
0
 

Expert Comment

by:camoh
ID: 25517351
Here is some helpful information that I found on the SAP Community Network that helped me come up with a work around to show that it is still working on generating my report.

The info below is what I copied from https://forums.sdn.sap.com/thread.jspa?threadID=1112190

********  Start of copied info  *******
The following sample code demonstrates how to retrieve the number of pages from your 'ReportDocument' object. Assuming that your 'ReportDocument object' is called 'crReport', use the following VB.NET code to return the number of pages in a report:
  ====================
 
 NOTE:
 
 Logon and parameter field values must be provided prior to executing this code.
 
 ====================
 
 Dim nPages as Integer
 
 nPages = crReport.FormatEngine.GetLastPageNumber(New CrystalDecisions.Shared.ReportPageRequestContext)

********  End of copied info  *******



Below is an example of my code in a vb.net application:'****** Code for frmReportViewer Class (My Windows form that contains the CrystalReportViewer1 control)******

Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared

Public Class frmReportViewer
    Private WithEvents rs As New clsReportStatus
    Private Delegate Sub BarUpdate(ByVal val As Integer)
    Private Delegate Sub ChangeCursor(ByVal myCursor As Windows.Forms.Cursor)
    Private Delegate Sub ctrlVisible(ByVal meVisible As Boolean)

    Private Sub Report_ProgressBarValue(ByVal val As Integer) Handles rs.ProgressBarValue
        Try
            If Me.InvokeRequired Then
                Dim bu As New BarUpdate(AddressOf Me.Report_ProgressBarValue)
                Me.Invoke(bu, New Object() {val})
            Else
                ProgressBar1.Value = val
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

    Private Sub Report_ctrlVisible(ByVal meVisible As Boolean) Handles rs.ctrlVisible
        Try
            If Me.InvokeRequired Then
                Dim lv As New ctrlVisible(AddressOf Me.Report_ctrlVisible)
                Me.Invoke(lv, New Object() {meVisible})
            Else
                lblWait.Visible = meVisible
                ProgressBar1.Visible = meVisible
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

    Private Sub Report_mCursor(ByVal myCursor As Windows.Forms.Cursor) Handles rs.mCursor
        Try
            If Me.InvokeRequired Then
                Dim mc As New ChangeCursor(AddressOf Me.Report_mCursor)
                Me.Invoke(mc, New Object() {myCursor})
            Else
                Cursor = myCursor
            End If
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
    End Sub

    Private Sub frmReportViewer_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            If Not rs.Running Then
                rs.StartThread()
            End If
            Application.DoEvents()

            Dim nPages As Integer

            Dim rep As New ReportDocument

            rep = Me.CrystalReportViewer1.ReportSource

            Me.Show()
            Application.DoEvents()
           'Here is where I inserted the line from the SAP Community Network forum
            nPages = rep.FormatEngine.GetLastPageNumber(New CrystalDecisions.Shared.ReportPageRequestContext)
            rs.StopThread()
        Catch ex As Exception
            rs.StopThread()
            MessageBox.Show(ex.Message)
        End Try
    End Sub
End Class




'****** Code for clsReportStatus Class ******

Public Class clsReportStatus
    Public Event ProgressBarValue(ByVal val As Integer)
    Public Event ctrlVisible(ByVal v As Boolean)
    Public Event mCursor(ByVal myCursor As Windows.Forms.Cursor)
    Private t As System.Threading.Thread
    Private aborting As Boolean = True

    Public ReadOnly Property Running() As Boolean
        Get
            Return Not aborting
        End Get
    End Property

    Public Sub StartThread()
        If aborting Then
            aborting = False
            t = New System.Threading.Thread(AddressOf ReportStatus)
            t.Start()
        End If
    End Sub

    Public Sub StopThread()
        aborting = True
    End Sub

    Private Sub ReportStatus()
        Try
            Dim intPos As Integer = 0
            RaiseEvent mCursor(Cursors.WaitCursor)
            RaiseEvent ProgressBarValue(intPos)
            RaiseEvent ctrlVisible(True)

            Do Until Not Me.Running
                'Do Until intPos = 100
                RaiseEvent ProgressBarValue(intPos)
                System.Threading.Thread.Sleep(300)
                If intPos < 100 Then
                    intPos = intPos + 1
                Else
                    intPos = 1
                End If
                Application.DoEvents()
            Loop

            RaiseEvent ProgressBarValue(100)
            System.Threading.Thread.Sleep(1000)
            RaiseEvent ctrlVisible(False)
            RaiseEvent mCursor(Cursors.Default)

        Catch ex As Exception
            RaiseEvent mCursor(Cursors.Default)
            MessageBox.Show(ex.Message)
            RaiseEvent ctrlVisible(False)
            Me.StopThread()
        End Try
    End Sub
End Class


0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question