This walkthrough illustrates how to set up a basic End-User Report Designer on a Windows Forms application in the Professional Edition of ActiveReports.
Note: This walkthrough requires the Microsoft .NET Framework version 4.0 or higher.
At the end of this walkthrough, the End-User Report Designer appears like the following image.
You will add the Designer that could only edit and preview a report file.
C# code. Paste AFTER the InitializeComponent method |
Copy Code
|
---|---|
public frmMain() { InitializeComponent(); designer.Toolbox = toolbox; } |
C# code. Paste at the top of the Form1 code view |
Copy Code
|
---|---|
using GrapeCity.ActiveReports.Design; |
C# code. Paste INSIDE the openToolStripMenuItem_Click handler |
Copy Code
|
---|---|
private void openToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); var dialogResult = openFileDialog.ShowDialog(); if (dialogResult == System.Windows.Forms.DialogResult.OK) { designer.LoadReport(new System.IO.FileInfo(openFileDialog.FileName)); } } |
C# code. Paste INSIDE the saveAsToolStripMenuItem_Click handler |
Copy Code
|
---|---|
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = GetSaveFilter(); var dialogResult = saveFileDialog.ShowDialog(); if (dialogResult == System.Windows.Forms.DialogResult.OK) { designer.SaveReport(new System.IO.FileInfo(saveFileDialog.FileName)); } } |
C# code. Paste AFTER the saveAsToolStripMenuItem_Click handler |
Copy Code
|
---|---|
private string GetSaveFilter() { switch (designer.ReportType) { case DesignerReportType.Section: return "Section Report Files (*.rpx)|*.rpx"; case DesignerReportType.Page: return "Page Report Files (*.rdlx)|*.rdlx"; case DesignerReportType.Rdl: return "RDL Report Files (*.rdlx)|*.rdlx"; default: return "RDL Report Files (*.rdlx)|*.rdlx"; } } |
C# code. Paste INSIDE the sectionToolStripMenuItem_Click handler |
Copy Code
|
---|---|
private void sectionToolStripMenuItem_Click(object sender, EventArgs e) { designer.NewReport(DesignerReportType.Section); } |
C# code. Paste INSIDE the pageReportToolStripMenuItem_Click handler |
Copy Code
|
---|---|
private void pageReportToolStripMenuItem_Click(object sender, EventArgs e) { designer.NewReport(DesignerReportType.Page); } |
C# code. Paste INSIDE the rdlReportToolStripMenuItem_Click handler |
Copy Code
|
---|---|
private void rdlReportToolStripMenuItem_Click(object sender, EventArgs e) { designer.NewReport(DesignerReportType.Rdl); } |
C# code. Paste at the top of the Form1 code view |
Copy Code
|
---|---|
using GrapeCity.ActiveReports.Export.Pdf.Page; using GrapeCity.ActiveReports.Rendering.IO; using GrapeCity.ActiveReports; using System.IO; |
C# code. Paste AFTER the InitializeComponent method |
Copy Code
|
---|---|
public frmMain() void designer_ActiveTabChanged(object sender, EventArgs e) |
C# code. Paste INSIDE the exportToolStripMenuItem_Click handler |
Copy Code
|
---|---|
private void exportToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Pdf (*.pdf)|*.pdf"; var dialogResult = saveFileDialog.ShowDialog(); if (dialogResult == System.Windows.Forms.DialogResult.OK) { var pdfRe = new PdfRenderingExtension(); var msp = new MemoryStreamProvider(); (designer.Report as PageReport).Document.Render(pdfRe, msp); using (var stream = msp.GetPrimaryStream().OpenStream()) using (var fileStream = new FileStream(saveFileDialog.FileName, FileMode.Create, FileAccess.Write)) { stream.CopyTo(fileStream); } MessageBox.Show("Export is done"); } |
For more information on export filters, rendering extensions and their settings, refer to the Exporting section of the ActiveReports User Guide.
Control | Name | Property Value |
---|---|---|
ReportExplorer | arReportExplorer |
ReportDesigner = designer |
LayerList | arLayerList |
ReportDesigner = designer |
PropertyGrid | arPropertyGrid | Resize and move as necessary. |
GroupEditor | arGroupEditor |
ReportDesigner = designer |
ReportsLibrary | arReportsLibrary | ReportDesigner = designer This binds the ActiveReports Designer to the ReportsLibrary control. Resize and move as necessary. |
Press F5 to run the project. The End User Report Designer opens with an RDL Report.
For information on how you can customize the End User Report Designer and more, refer to the End User Designer product sample.