Help decoupling Crystal Report from CrystalReportViewer
Posted
by John at CashCommons
on Stack Overflow
See other posts from Stack Overflow
or by John at CashCommons
Published on 2010-03-15T23:45:35Z
Indexed on
2010/03/15
23:49 UTC
Read the original article
Hit count: 331
I'm using Visual Studio 2005 with VB.NET.
I have a number of Crystal Reports, each with their own associated dialog resource containing a CrystalReportViewer. The class definitions look like this:
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
I basically instantiate the dialog, set theItems to the list I want, and call ShowDialog.
I now have a need to combine several of these reports into one report (possibly like this) but the code that loads up the fields in the report is in the dialog.
How would I go about decoupling the report initialization from the dialog?
Thanks!
© Stack Overflow or respective owner