处理Crystal Reports

时间:2010-10-06 13:44:16

标签: arrays vb.net crystal-reports idisposable

我设置了多个报告查看器,每个查看器都可以打开一些水晶报告。 一切正常。

我想简化处理DisposeOfReports()事件中报告的方式。

在那一刻我做了以下事情:

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

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

可以使用数组完成吗?

我在想每次生成报告时都可以将报告添加到数组中。

然后在DisposeOfReports()事件中做类似的事情:

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

对于这种方法,我打算像这样声明reportsArray:

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

请人们可以反馈给我,让我知道这是否是一种有效的方法,或者有更好的方法吗?

干杯。

1 个答案:

答案 0 :(得分:1)

我认为你的做法没有错。