Handling events raised

KrAcKeD

Member
Joined
Jul 14, 2006
Messages
9
Programming Experience
5-10
Hi,

I Have a Windows Form to which I linked classes that generates reports using crystal report.

I want thoses classes to be independant of the Form but I want the Form to display the progress bar to show the progress of the class in creating the Report.

I though of 2 ways to do this,

#1- Make the class set a public value for the progress of the creation of the report and make a thread in the Form that would go and request the process of the class every X seconds.

#2- Create events in my class and handle them with the Form to display the proper progress of the class.

I went for the option #2, I though it was easier that way, creating threads for a progress bar seemed too much work for what it would of done.

So I have something that looks like this

VB.NET:
Public Class clsCrystalReport
    Public Event Ev_Event()
[...]
'---
    Public Sub GenerateReport([...])
[...]
        RaiseEvent Ev_Event()
[...]
End Class
'---
Public Class frmMain
[...]
    WithEvents RptCrystalReport as clsCrystalReport
[...]
'---
    Public Sub GenerateReport([...])
[...]
        RptCrystalReport = new clsCrystalReport([...])
[...]
'---
    Private Sub GetEvent() Handles RptCrystalReport.Ev_Event
        MsgBox("Event")
    End Sub
When I put the GetEvent function inside the clsCrystalReport class, the event is caught, but when it's in the class that instanciate the class, it doesn't.

How can I solve this problem to be able to display a progress bar in an interface that is independant of the class it creates ?
 
Back
Top