ActiveReports 9 > ActiveReports User Guide > Samples and Walkthroughs > Walkthroughs > Common Walkthroughs > Professional > Creating a Basic End User Report Designer (Pro Edition) |
This walkthrough illustrates how to set up a basic End-User Report Designer on a Windows Forms application in the Professional Edition of ActiveReports.
At the end of this walkthrough, the End-User Report Designer appears like the following image.
Note: See Adding ActiveReports Controls, if you need help with adding the Designer control or any other ActiveReports controls to your Visual Studio toolbox. |
Control | Parent | Name | Dock | Property Value |
---|---|---|---|---|
ToolStripContainer | formDesigner | toolStripContainer | Fill | LeftToolStripPanel - Enabled = False RightToolStripPanel - Enabled = False |
SplitContainer | toolStripContainer | splitContainer | Fill | FixedPanel = Panel1 |
Designer | splitContainer.Panel2 | arDesigner | None | Anchor = Top, Bottom, Left, Right Resize and move as necessary. |
TabControl | splitContainer.Panel2 | tabControl | None | Anchor = Right Resize and move as necessary. |
ReportExplorer | tabControl.tabPage1 | arReportExplorer | None |
ReportDesigner = arDesigner |
LayerList | tabControl.tabPage2 | arLayerList | None |
ReportDesigner = arDesigner |
PropertyGrid | splitContainer.Panel2 | arPropertyGrid | None | Anchor = Top, Bottom, Right Resize and move as necessary. |
Toolbox | splitContainer.Panel1 | arToolbox | Fill | - |
Add the following code to create a data group in the toolbox. This code creates a LoadTools method that you can call in the formDesigner_Load event to load the data toolbox group into the toolbox.
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
|
---|---|
Imports GrapeCity.ActiveReports.Design
|
Visual Basic.NET code. Paste INSIDE the formDesigner class. |
Copy Code
|
---|---|
Private Sub LoadTools(ByVal arToolbox As 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 ABOVE the formDesigner class. |
Copy Code
|
---|---|
using GrapeCity.ActiveReports.Design;
|
C# code. Paste INSIDE the formDesigner class. |
Copy Code
|
---|---|
private void LoadTools(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"); } |
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 |
C# code. Paste INSIDE the formDesigner class. |
Copy Code
|
---|---|
private void OnExit(object sender, EventArgs e) { Close(); } |
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 the 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 = toolStripContainer.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) |
C# code. Paste INSIDE the formDesigner Load event. |
Copy Code
|
---|---|
// Add controls to the toolbox LoadTools(arToolbox); arDesigner.Toolbox = arToolbox; // Add Menu and ToolStrip to the 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 = ToolStripContainer.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); |
Layers are supported in Page Reports and Rdl Reports, so the Layer List options appear disabled in Section Reports. Follow the steps below to remove the Layer List from Section Report.
Visual Basic.NET code. Paste INSIDE the formDesigner class. |
Copy Code
|
---|---|
' Create the event handler
Public Sub New()
InitializeComponent()
AddHandler Me.arDesigner.LayoutChanged, AddressOf OnLayoutChanged
End Sub
|
C# code. Paste INSIDE the formDesigner method. |
Copy Code
|
---|---|
// Create the event handler this.arDesigner.LayoutChanged += new LayoutChangedEventHandler(OnLayoutChanged); |
Visual Basic.NET code. Paste INSIDE the formDesigner class. |
Copy Code
|
---|---|
Private Sub OnLayoutChanged(ByVal sender As System.Object, ByVal e As LayoutChangedArgs) Handles arDesigner.LayoutChangedEnd Sub |
C# code. Paste INSIDE the formDesigner class. |
Copy Code
|
---|---|
private void OnLayoutChanged(object sender, LayoutChangedArgs e){} |
Visual Basic.NET code. Paste INSIDE the OnLayoutChanged function. |
Copy Code
|
---|---|
If arDesigner.ReportType = DesignerReportType.Section Then tabControl.TabPages.Remove(TabPage1) tabControl.TabPages.Remove(TabPage2) tabControl.TabPages.Add(TabPage1) tabControl.Refresh() End If If arDesigner.ReportType = DesignerReportType.Page Then tabControl.TabPages.Remove(TabPage1) tabControl.TabPages.Remove(TabPage2) tabControl.TabPages.Add(TabPage1) tabControl.TabPages.Add(TabPage2) tabControl.Refresh() End If If arDesigner.ReportType = DesignerReportType.Rdl Then tabControl.TabPages.Remove(TabPage1) tabControl.TabPages.Remove(TabPage2) tabControl.TabPages.Add(TabPage1) tabControl.TabPages.Add(TabPage2) tabControl.Refresh() End If |
C# code. Paste INSIDE the OnLayoutChanged function. |
Copy Code
|
---|---|
if (arDesigner.ReportType == DesignerReportType.Section) { tabControl.TabPages.Remove(tabPage1); tabControl.TabPages.Remove(tabPage2); tabControl.TabPages.Add(tabPage1); tabControl.Refresh(); } if (arDesigner.ReportType == DesignerReportType.Page) { tabControl.TabPages.Remove(tabPage1); tabControl.TabPages.Remove(tabPage2); tabControl.TabPages.Add(tabPage1); tabControl.TabPages.Add(tabPage2); tabControl.Refresh(); } if (arDesigner.ReportType == DesignerReportType.Rdl) { tabControl.TabPages.Remove(tabPage1); tabControl.TabPages.Remove(tabPage2); tabControl.TabPages.Add(tabPage1); tabControl.TabPages.Add(tabPage2); tabControl.Refresh(); } |
Visual Basic.NET code. Paste INSIDE the OnLayoutChanged function. |
Copy Code
|
---|---|
OnLayoutChanged(Nothing, Nothing) |
C# code. Paste INSIDE the OnLayoutChanged function. |
Copy Code
|
---|---|
OnLayoutChanged(null, null); |
You can also customize the End User Report Designer further by disabling the Section Report tab in the Page or RDL report toolbox. For this and other customizations refer to the End User Designer product sample.