开发者

Disposing of Crystal Reports

开发者 https://www.devze.com 2023-01-19 10:07 出处:网络
I have a number of report viewers set up, each of which can open a number of crystal reports. This all works fine.

I have a number of report viewers set up, each of which can open a number of crystal reports. This all works fine.

I am wanting to streamline how I dispose of the reports in the DisposeOfReports() event.

At the minute I do the following:

 If (_rpt1 IsNot Nothing) Then
     _rpt1.Close()
     _rpt1.Dispose()
 End If

 If (_rpt2 IsNot Nothing) Then
     _rpt2.Close()
     _rpt2.Dispos开发者_运维知识库e()
 End If

Can this be done using an array?

I was thinking each time a report is generated I could add the report to the array.

Then in the DisposeOfReports() Event do something like:

If (reportsArray IsNot Nothing) Then

  For Each report As CrystalDecisions.CrystalReports.Engine.ReportClass In reportsArray

     If (report IsNot Nothing) Then
        report.Close()
        report.Dispose()
     End If

  Next

  reportsArray = Nothing

 End If

For this method I was going to declare reportsArray like this:

Private reportsArray As New List(Of CrystalDecisions.CrystalReports.Engine.ReportDocument)

Please can people feed back to me on this and let me know if this is a valid method of doing this or if there are better ways of doing it?

Cheers.


I see nothing wrong with your approach.

0

精彩评论

暂无评论...
验证码 换一张
取 消