ActiveReports for .NET 3 Online Help Request technical support
Walkthrough: Adding Code for the End-User Report Designer
See Also
User Guide > Samples and Walkthroughs > Walkthroughs > Professional Edition Walkthroughs > Creating an End-User Report Designer Walkthroughs > Walkthrough: Adding Code for the End-User Report Designer

Glossary Item Box

This walkthrough builds on the steps completed in the previous walkthrough, Creating the Basic Layout for an End-User Report Designer, and 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.

Adding a Reference to the ToolBoxClassLib DLL 

To add the reference

  1. In the Solution Explorer, right-click on the References folder.
  2. In the Add Reference dialog, click the Browse button. For Visual Studio 2005, select the "Browse" tab.
  3. Navigate to the directory that contains the samples and select \Samples\CSharp\Professional\EndUserDesigner. If you are developing with VB.NET, select \Samples\VB\Professional\EndUserDesigner.
  4. Select DataDynamics.ActiveReports.ToolBoxClassLib.dll and click OK.
Adding this reference exposes DataDynamics' packaged ToolBoxService. If you wish to further customize the ToolBox, you can access the source files at ActiveReports for .NET 3.0\Samples\ToolBoxClassLib in the directory at which your samples are installed. No support is provided for such customization.

Adding Imports/using statements

To add the statements

To write the code in Visual Basic or C#

The following example shows what the code looks like.

'Visual Basic
'Add the following Imports statements
Imports DataDynamics.ActiveReports
Imports DataDynamics.ActiveReports.Design
Imports DataDynamics.ActiveReports.Design.Toolbox

//C#
//Add the following using statements 
using DataDynamics.ActiveReports;
using DataDynamics.ActiveReports.Design;
using DataDynamics.ActiveReports.Design.Toolbox;

Adding code to the formDesigner_Load event

To write the code in Visual Basic or C#

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

Adding code to create a data toolbox group

To write the code in Visual Basic or C#

The following example shows what the code looks like.

'Visual Basic
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

//C#
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");
}

Adding code to enable shortcut keys to work with the CommandBarManager

To write the code in Visual Basic or C#

The following example shows what the code looks like.

'Visual Basic
Protected Overrides Function ProcessCmdKey(ByRef msg As Message, ByVal keyData As Keys) As Boolean
    If Me.arDesigner.Focused Then 
        If Me.arDesigner.CommandBarManager.PreProcessMessage(msg) Then
           Return True
        End If
    End If
    Return MyBase.ProcessCmdKey(msg, keyData)
End Function

//C#
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
    if(this.arDesigner.CommandBarManager.PreProcessMessage(ref msg))
       return true;
    return base.ProcessCmdKey(ref msg, keyData);
}

Adding code to the arDesigner_SelectionChanged event

To write the code in Visual Basic

To write the code in C#

Adding code to close the End-User Report Designer when the Exit command is clicked on the File menu  

To write the code in Visual Basic

To write the code in C#

See Also

©2009. All Rights Reserved.