1

我正在使用带有 VB.NET 的 Visual Studio 2005。

我有许多 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。

我现在需要将这些报告中的几个合并到一个报告中(可能像这样),但是在报告中加载字段的代码在对话框中。

我将如何将报告初始化与对话框分离?

谢谢!

4

1 回答 1

1

您可以很容易地拥有一个通用的报告查看对话框,该对话框采用报告的基类实例 (Ie CrystalReport) 并让它显示 - 您不需要一直强烈地键入报告。

于 2010-03-16T08:56:21.253 回答