ActiveReports 6 Online Help Send comments on this topic.
Creating a Basic End User Report Designer (Pro Edition)
See Also
ActiveReports 6 > ActiveReports User Guide > Samples and Walkthroughs > Walkthroughs > Creating a Basic End User Report Designer (Pro Edition)

Glossary Item Box

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 form. (The Designer control is not supported on the Web.)

Note: The Designer control requires the .NET Framework full profile version. To ensure you are using the full profile version, go to the Visual Studio Project Properties, then to the Compile tab, Advanced Compile Options... (for Visual Basic projects) or to the Application tab (for C# projects) and in the Target framework field select a full profile version.

This walkthrough is split up into the following activities:

When you have finished this walkthrough, you will have a working end-user report designer that looks like the following.


Click to EnlargeClick to Enlarge
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

  1. Change the Name property of your Windows form to formDesigner.
  2. Resize the form so that you can comfortably add the controls.
  3. Drag the following controls in the order listed from the Visual Studio toolbox onto the form, setting the properties as indicated. (If you have not yet added the ActiveReports controls to your toolbox, see the Adding ActiveReports Controls topic.)

    ShowControls for the form

    Control Parent Name Dock Miscellaneous
    ToolStripContainer formDesigner ToolStripContainer1 Fill LeftToolStripPanel Enabled = False;
    RightToolStripPanel Enabled = False
    SplitContainer ToolStripContainer1 SplitContainer1 Fill
    StatusStrip ToolStripContainer1 BottomToolStripPanel arStatus
    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.
    Toolbox SplitContainer1 Panel1 arToolbox Fill
    PropertyGrid SplitContainer1 Panel2 arPropertyGrid None Anchor = Top, Bottom, Right;
    Resize and move as necessary.
  4. Select arDesigner and in the Properties window, drop down the PropertyGrid property and select arPropertyGrid.
  5. With the controls added in the correct order and all of the above properties set, the form looks similar to the following:

    Click to EnlargeClick to Enlarge

To import the Toolbox library

  1. Right-click the form and select View Code.
  2. In the code view that appears, add the following code to give your project access to the Toolbox library.

The following examples show what the code looks like.

ShowTo write the code in Visual Basic.NET

Visual Basic.NET code. Paste ABOVE the formDesigner class. Copy Code
'Visual Basic
'Add the following Imports statements
Imports DataDynamics.ActiveReports
Imports DataDynamics.ActiveReports.Design
Imports DataDynamics.ActiveReports.Design.Toolbox

ShowTo write the code in C#

C# code. Paste ABOVE the formDesigner class. Copy Code
//C#
//Add the following using statements 
using DataDynamics.ActiveReports;
using DataDynamics.ActiveReports.Design;
using DataDynamics.ActiveReports.Design.Toolbox;

To add an OnExit method

  1. Right-click in any section of formDesigner, and select View Code.
  2. In the code view that appears, add the following code to create an OnExit method that you can call from the Exit menu item we create in the next procedure.

The following examples show what the code looks like.

ShowTo write the code in Visual Basic.NET

Visual Basic.NET code. Paste INSIDE the formDesigner class. Copy Code
'Visual Basic
Private Sub OnExit(ByVal sender As Object, ByVal e As EventArgs)
   Close()
End Sub

ShowTo write the code in C#

C# code. Paste INSIDE the formDesigner class. Copy Code
//C#
private void OnExit(object sender, EventArgs e)
{
    Close();
}

To create a data toolbox group

  1. Add the following code right after the OnExit method to create a data group on the toolbox.
  2. This code creates a LoadTools method that you can call in the formDesigner Load event to load the new toolbox group into the toolbox.

The following examples show what the code looks like.

ShowTo write the code in Visual Basic.NET

Visual Basic.NET code. Paste INSIDE the formDesigner class. Copy Code
Private Sub LoadTools(ByVal arToolbox As DataDynamics.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

ShowTo write the code in C#

C# code. Paste INSIDE the formDesigner class. Copy Code
private void LoadTools(DataDynamics.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, toolstrips and status bar

  1. In the Design view of the form, double-click the title bar of formDesigner. This creates an event-handling method for the formDesigner Load event.
  2. Add code to the handler to:
    • Set up the toolbox
    • Set up the menu and tool strips
    • Add an Exit command to the menu
    • Set up the status bar

The following examples show what the code for the method looks like.

ShowTo write the code in Visual Basic.NET

Visual Basic.NET code. Paste INSIDE the formDesigner Load event. Copy Code
'Note:  Assigning the ToolBox to the designer before calling NewReport
' automatically adds the default controls to the toolbox in a group called
' "ActiveReports 6"
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", DataDynamics.ActiveReports.Design.Images.Delete, 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)

'Set up the Status Bar
Dim tsLabel1 As ToolStripStatusLabel = New ToolStripStatusLabel()
tsLabel1.Spring = True
tsLabel1.BorderStyle = Border3DStyle.Sunken
arStatus.Items.Add(tsLabel1)

ShowTo write the code in C#

C# code. Paste INSIDE the formDesigner Load event. Copy Code
//C#
//Note:  Assigning the ToolBox to the designer before calling NewReport
// automatically adds the default controls to the toolbox in a group called
// "ActiveReports 6"
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", DataDynamics.ActiveReports.Design.Images.Delete, 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);

//Set up the Status Bar
ToolStripStatusLabel tsLabel1 = new ToolStripStatusLabel();
tsLabel1.Spring = true;
tsLabel1.BorderStyle = Border3DStyle.Sunken;
arStatus.Items.Add(tsLabel1);

To display the selected object in the status bar

The following examples show what the code to display objects in the status bar looks like.

ShowTo write the code in Visual Basic.NET

  1. Right-click in any section of formDesigner, and select View Code to display the code view for the Windows Form.
  2. At the top left of the code view for formDesigner, click the drop-down arrow and select arDesigner.
  3. At the top right of the code window, click the drop-down arrow and select SelectionChanged. This creates an event-handling method for the arDesigner SelectionChanged event.

The following example shows what the code for the method looks like.

Visual Basic.NET code. Paste INSIDE the SelectionChanged event. Copy Code
'Display the current selection in the designer's status bar
Dim curSelection As String = ""
Dim selectionEnum As IEnumerator = Nothing
If Not (arDesigner.Selection Is Nothing) Then
   selectionEnum = arDesigner.Selection.GetEnumerator()
End If
While Not (selectionEnum Is Nothing) AndAlso selectionEnum.MoveNext()
    If TypeOf selectionEnum.Current Is Section Then
        curSelection = curSelection + (CType(selectionEnum.Current, Section)).Name + ", "
    End If
    If TypeOf selectionEnum.Current Is ARControl Then
        curSelection = curSelection + (CType(selectionEnum.Current, ARControl)).Name + ", "
    End If
    If TypeOf selectionEnum.Current Is Field Then
        curSelection = curSelection + (CType(selectionEnum.Current, Field)).Name + ", "
    End If
    If TypeOf selectionEnum.Current Is Parameter Then
        curSelection = curSelection + (CType(selectionEnum.Current, Parameter)).Key + ", "
    End If
    If TypeOf selectionEnum.Current Is ActiveReport Then
        curSelection = curSelection + (CType(selectionEnum.Current, ActiveReport)).Document.Name + ", "
    End If
End While
If Me.arStatus.Created AndAlso Not (Me.arStatus.Items(0) Is Nothing) Then
    If Not (curSelection = "") Then
        Me.arStatus.Items(0).Text = "Current Selection: " + curSelection.Substring(0, curSelection.Length - 2)
    Else
        Me.arStatus.Items(0).Text = "No Selection"
    End If
End If

ShowTo write the code in C#

  1. Click in the designer control on formDesigner to select arDesigner.
  2. Click on the events icon in the Properties window to display available events for the control.
  3. Double-click SelectionChanged. This creates an event-handling method for the arDesigner_SelectionChanged event.
C# code. Paste INSIDE the SelectionChanged event. Copy Code
//C#
//This will display the current selection in the designer's status bar
string curSelection = "";
System.Collections.IEnumerator selectionEnum = null;
if(arDesigner.Selection != null)
    selectionEnum = arDesigner.Selection.GetEnumerator();
while(selectionEnum != null && selectionEnum.MoveNext())
{
    if(selectionEnum.Current is Section)
       curSelection = curSelection + (selectionEnum.Current as Section).Name + ", ";
    if(selectionEnum.Current is ARControl)
       curSelection = curSelection + (selectionEnum.Current as ARControl).Name + ", ";
    if(selectionEnum.Current is Field)
       curSelection = curSelection + (selectionEnum.Current as Field).Name + ", ";
    if(selectionEnum.Current is Parameter)
       curSelection = curSelection + (selectionEnum.Current as Parameter).Key + ", ";
    if(selectionEnum.Current is ActiveReport)
       curSelection = curSelection + (selectionEnum.Current as ActiveReport).Document.Name + ", ";
}
if(this.arStatus.Created && this.arStatus.Items[0] != null)
{
    if(curSelection != "")
       this.arStatus.Items[0].Text = "Current Selection: " + curSelection.Substring(0, curSelection.Length - 2);
    else
       this.arStatus.Items[0].Text = "No Selection";
}

See Also