ActiveReports 8 > ActiveReports User Guide > Samples and Walkthroughs > Walkthroughs > Common Walkthroughs > Professional > Creating a Basic End User Report Designer (Pro Edition) |
Using ActiveReports Professional Edition, you can set up a custom end-user report designer. This walkthrough illustrates how to set up a basic end-user report designer on a Windows Forms application (The Designer control is not supported on a Web application).
This walkthrough is split into the following activities:
When you have finished this walkthrough, you will have a working end-user report designer that looks like the following.
Note: If you need help with adding the Designer controls to your Visual Studio toolbox, see Adding ActiveReports Controls. |
To add controls to the Form
Controls for the form
Control | Parent | Name | Dock | Property Value |
---|---|---|---|---|
ToolStripContainer | formDesigner | ToolStripContainer1 | Fill | LeftToolStripPanel - Enabled = False RightToolStripPanel - Enabled = False |
SplitContainer | ToolStripContainer1 | SplitContainer1 | Fill | FixedPanel = Panel1 |
Designer | SplitContainer1.Panel2 | arDesigner | None | Anchor = Top, Bottom, Left, Right Resize and move as necessary. |
ReportExplorer | SplitContainer1.Panel2 | arReportExplorer | None | ReportDesigner = arDesigner Anchor = Top, Right Resize and move as necessary. |
PropertyGrid | SplitContainer1.Panel2 | arPropertyGrid | None | Anchor = Top, Bottom, Right Resize and move as necessary. |
Toolbox | SplitContainer1.Panel1 | arToolbox | Fill | - |
To import the Toolbox library
The following examples show what the code looks like.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste ABOVE the formDesigner class. |
Copy Code
|
---|---|
'Add the following Imports statements Imports GrapeCity.ActiveReports Imports GrapeCity.ActiveReports.Design Imports GrapeCity.ActiveReports.Design.Toolbox Imports GrapeCity.ActiveReports.SectionReportModel Imports GrapeCity.ActiveReports.Data |
To write the code in C#
C# code. Paste ABOVE the formDesigner class. |
Copy Code
|
---|---|
//Add the following using statements using GrapeCity.ActiveReports; using GrapeCity.ActiveReports.Design; using GrapeCity.ActiveReports.Design.Toolbox; using GrapeCity.ActiveReports.SectionReportModel; using GrapeCity.ActiveReports.Data; |
To add the OnExit method
The following examples show what the code looks like.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the formDesigner class. |
Copy Code
|
---|---|
Private Sub OnExit(ByVal sender As Object, ByVal e As EventArgs) MyBase.Close() End Sub |
To write the code in C#
C# code. Paste INSIDE the formDesigner class. |
Copy Code
|
---|---|
private void OnExit(object sender, EventArgs e) { Close(); } |
To create a data toolbox group
The following examples show what the code looks like.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the formDesigner class. |
Copy Code
|
---|---|
Private Sub LoadTools(ByVal arToolbox As GrapeCity.ActiveReports.Design.Toolbox.Toolbox) 'Add Data Providers Me.arToolbox.AddToolboxItem(New System.Drawing.Design.ToolboxItem(GetType(System.Data.DataSet)), "Data") Me.arToolbox.AddToolboxItem(New System.Drawing.Design.ToolboxItem(GetType(System.Data.DataView)), "Data") Me.arToolbox.AddToolboxItem(New System.Drawing.Design.ToolboxItem(GetType(System.Data.OleDb.OleDbConnection)), "Data") Me.arToolbox.AddToolboxItem(New System.Drawing.Design.ToolboxItem(GetType(System.Data.OleDb.OleDbDataAdapter)), "Data") Me.arToolbox.AddToolboxItem(New System.Drawing.Design.ToolboxItem(GetType(System.Data.Odbc.OdbcConnection)), "Data") Me.arToolbox.AddToolboxItem(New System.Drawing.Design.ToolboxItem(GetType(System.Data.Odbc.OdbcDataAdapter)), "Data") Me.arToolbox.AddToolboxItem(New System.Drawing.Design.ToolboxItem(GetType(System.Data.SqlClient.SqlConnection)), "Data") Me.arToolbox.AddToolboxItem(New System.Drawing.Design.ToolboxItem(GetType(System.Data.SqlClient.SqlDataAdapter)), "Data") End Sub |
To write the code in C#
C# code. Paste INSIDE the formDesigner class. |
Copy Code
|
---|---|
private void LoadTools(GrapeCity.ActiveReports.Design.Toolbox.Toolbox arToolbox) { //Add Data Providers this.arToolbox.AddToolboxItem(new System.Drawing.Design.ToolboxItem(typeof(System.Data.DataSet)), "Data"); this.arToolbox.AddToolboxItem(new System.Drawing.Design.ToolboxItem(typeof(System.Data.DataView)), "Data"); this.arToolbox.AddToolboxItem(new System.Drawing.Design.ToolboxItem(typeof(System.Data.OleDb.OleDbConnection)), "Data"); this.arToolbox.AddToolboxItem(new System.Drawing.Design.ToolboxItem(typeof(System.Data.OleDb.OleDbDataAdapter)), "Data"); this.arToolbox.AddToolboxItem(new System.Drawing.Design.ToolboxItem(typeof(System.Data.Odbc.OdbcConnection)), "Data"); this.arToolbox.AddToolboxItem(new System.Drawing.Design.ToolboxItem(typeof(System.Data.Odbc.OdbcDataAdapter)), "Data"); this.arToolbox.AddToolboxItem(new System.Drawing.Design.ToolboxItem(typeof(System.Data.SqlClient.SqlConnection)), "Data"); this.arToolbox.AddToolboxItem(new System.Drawing.Design.ToolboxItem(typeof(System.Data.SqlClient.SqlDataAdapter)), "Data"); } |
To set up the designer's toolbox, menus and toolstrips
The following examples show what the code for the method looks like.
To write the code in Visual Basic.NET
Visual Basic.NET code. Paste INSIDE the formDesigner Load event. |
Copy Code
|
---|---|
' Add controls to the toolbox LoadTools(arToolbox) arDesigner.Toolbox = arToolbox ' Add Menu and ToolStrips to Form Dim menuStrip As ToolStrip = arDesigner.CreateToolStrips(DesignerToolStrips.Menu)(0) Dim fileMenu As ToolStripDropDownItem = CType(menuStrip.Items(0), ToolStripDropDownItem) ' Add an Exit command to the File menu fileMenu.DropDownItems.Add(New ToolStripMenuItem("Exit", Nothing, AddressOf OnExit)) Dim panel As ToolStripPanel = ToolStripContainer1.TopToolStripPanel panel.Join(menuStrip, 0) panel.Join(arDesigner.CreateToolStrips(DesignerToolStrips.Zoom)(0), 1) panel.Join(arDesigner.CreateToolStrips(DesignerToolStrips.Undo)(0), 1) panel.Join(arDesigner.CreateToolStrips(DesignerToolStrips.Edit)(0), 1) panel.Join(arDesigner.CreateToolStrips(DesignerToolStrips.Report)(0), 1) panel.Join(arDesigner.CreateToolStrips(DesignerToolStrips.Layout)(0), 2) panel.Join(arDesigner.CreateToolStrips(DesignerToolStrips.Format)(0), 2) |
To write the code in C#
C# code. Paste INSIDE the formDesigner Load event. |
Copy Code
|
---|---|
// Add controls to the toolbox LoadTools(arToolbox); arDesigner.Toolbox = arToolbox; // Add Menu and CommandBar to Form ToolStrip menuStrip = arDesigner.CreateToolStrips(DesignerToolStrips.Menu)[0]; ToolStripDropDownItem fileMenu = (ToolStripDropDownItem)menuStrip.Items[0]; // Add an Exit command to the File menu fileMenu.DropDownItems.Add(new ToolStripMenuItem("Exit", null, this.OnExit)); ToolStripPanel panel = ToolStripContainer1.TopToolStripPanel; panel.Join(menuStrip, 0); panel.Join(arDesigner.CreateToolStrips(DesignerToolStrips.Zoom)[0], 1); panel.Join(arDesigner.CreateToolStrips(DesignerToolStrips.Undo)[0], 1); panel.Join(arDesigner.CreateToolStrips(DesignerToolStrips.Edit)[0], 1); panel.Join(arDesigner.CreateToolStrips(DesignerToolStrips.Report)[0], 1); panel.Join(arDesigner.CreateToolStrips(DesignerToolStrips.Layout)[0], 2); panel.Join(arDesigner.CreateToolStrips(DesignerToolStrips.Format)[0], 2); |
To view an End User Report Designer