ActiveReports allows reports to be saved into their own standard format called an RDF file (Report Document Format). Once a report has been saved to an RDF file, it can be loaded into the viewer control and used to display reports in custom preview applications.
To write the code to save a report as an RDF file in Visual Basic
- Right-click in any section of the Windows Form, and click on View Code to display the code view for the Windows Form. Add the following code to create the saveRDF event.
To write the code to save a report as an RDF file in C#
- Double-click on the Windows Form to see the code view for the Windows form. Add the following code to create the SaveRDF event.
'Visual Basic Dim rpt As New ActiveReport1() Private Sub saveRDF() rpt.Run() rpt.Document.Save(Application.StartupPath + "\\NewRDF.RDF") End Sub //C# private void saveRDF() { ActiveReport1 rpt = new ActiveReport1(); rpt.Run(); rpt.Document.Save(Application.StartupPath + "\\NewRDF.RDF"); }
To write the code to load the saved RDF into the ActiveReports viewer in Visual Basic or C#
- Right-click in any section of the Windows Form, and click on View Code to display the code view for the Windows Form. Add the following code to create the LoadRDF event.
'Visual Basic Private Sub LoadRDF() rpt.Run() Viewer1.Document.Load(Application.StartupPath + "\\NewRDF.RDF") End Sub //C# private void LoadRDF() { ActiveReport1 rpt = new ActiveReport1(); rpt.Run(); viewer1.Document.Load(Application.StartupPath + "\\NewRDF.RDF"); }