我正在使用Visual Studio 2005和VB.NET。
我有许多Crystal Reports,每个都有自己的关联对话框资源,包含CrystalReportViewer。类定义如下所示:
Imports System.Windows.Forms
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Public Class dlgForMyReport
Private theReport As New myCrystalReport
Public theItems As New List(Of MyItem)
Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.OK
Me.Close()
End Sub
Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Close()
End Sub
Private Sub dlgForMyReport_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
theReport.SetDataSource(theItems)
'Do a bunch of stuff here to set data items in theReport
Me.myCrystalReportViewer.ReportSource = theReport
End Sub
End Class
我基本上实例化对话框,将theItems设置为我想要的列表,然后调用ShowDialog。
我现在需要将其中一些报告合并到一个报告中(possibly like this),但加载报告中字段的代码位于对话框中。
我如何将报告初始化与对话框解耦?
谢谢!
答案 0 :(得分:1)
您可以很容易地拥有一个通用报告查看对话框,该对话框为报告(即CrystalReport
)提供了基类的实例,并让它显示 - 您不需要 强烈地输入报告。