cancel
Showing results for 
Search instead for 
Did you mean: 

Clear Crystal Report from Addin

Former Member
0 Kudos

Hi there,

I am creating an addin for Crystal Reports 2008. Now, I would like to clear the shown report from within the addin.

Changing the datasource is no problem but some of the field still remain on the reports as well as the images. Is there an easy way to clear the whole document to have a blank report?

Thanks,

Pascal

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hello, Pascal;

Are you creating reports in Visual Studio .NET?

Normally you would create all of the reports you need with the fields as you require them. Then you pass each report object to a ReportDocument object releasing the report when you are finished with it, in the form unload of the viewer for example. Then load the next report required.

Here is an example I use for testing:

Dim crReportDocument As ReportDocument

Dim ReportFileName As String

Private Sub ConfigureCrystalReports()

'Create a new instance of your report object

crReportDocument = New ReportDocument()

'OpenFileDialog1 component to choose report

OpenFileDialog1.InitialDirectory = "c:\"

OpenFileDialog1.Filter = "rpt files (.rpt)|.rpt|All files (.)|."

OpenFileDialog1.ShowDialog()

OpenFileDialog1.RestoreDirectory = True

'Passes full path to the report

ReportFileName = OpenFileDialog1.FileName()

'Load the report document

crReportDocument.Load(ReportFileName, OpenReportMethod.OpenReportByTempCopy)

'Add any code you need e.g. logon to the database or pass a Selection Formula

'Pass the report to the viewer

myCrystalReportViewer.ReportSource = crReportDocument

End Sub

Elaine

Former Member
0 Kudos

Hm, maybe it did not state that clearly: I would like to clean an existing report of any fields etc. that are inside. I managed it myself by removing all tables rom the database controller.

Pascal

Answers (1)

Answers (1)

Former Member
0 Kudos

Hello, Pascal;

What method are you using to create the Addin? Could you explain more about what you are doing and what your requirements are?

You would have to loop through all of the report objects and delete them.

What would your plan be for putting each object you require back for the next report display? Creating a report at runtime takes special functionality and in some cases special licensing. It is not the usual way to display different reports at runtime.

Elaine