Getting Started: SharpShooter Report.Win

System Requirements

 

To use SharpShooter Reports.Win successfully in WinForms applications you need: 

  • .NET Framework 2.0, 3.5, 4.0, 4.5 platform
  • Microsoft Visual Studio 2005/2008/2010/2012
  • Windows XP/Vista/Seven/8

Installation

Run *.msi file (in our example SharpShooterCollection.msi) as Administrator

to start the installation wizard.

Follow the on screen instructions and click “Next”. The license agreement screen is displayed.

Read the license agreement. To accept its terms and proceed with the installation,

select the “I agree” button and click “Next”.

 

Accept the default installation directory or choose a directory in which to install

SharpShooter Collection. Then click “Next”.


At the “Additional Options” step select the following options:

  •     Copy dlls to GAC. ( For more information on Global Assembly Cache refer to
http://msdn.microsoft.com/en-us/library/yf1d93sz.aspx.)

  •     Add components to Visual Studio Toolbox. (It is possible to install the Toolbox
components later manually if they are not selected in this step.)

 

Developing

Step 1. Creating an Application

When you create an application in Visual Studio, you first create a project. For this example,

you’ll create a Windows Forms Application project.

To create a new project in Microsoft Visual Studio, select the “New > Project…” from the File menu.

This opens the “New Project” dialog box.

Choose “Windows Forms Application” template in the middle pane. In the “Name” box,

type a name for the new project.  In the “Location” box, select a save location.

Make sure that the “Create directory for solution” check box is selected.  Then click “OK”.

The project is created and the different files appear in Solution Explorer.

 

Step 2. Creating and Populating a Data Source

To bring data into your application you will need to establish connection with a data source,

in other words, to bind data to your application.

To do this, open the main form of the application in the editor by double clicking

on the “Form1.cs” in the Solution Explorer.

Switch to Toolbox and choose the DataSet element from Data group to set data structure.

(Note: Datasets are objects that contain data tables where you can temporarily store the data

for use in your application.)

To add the element to your form, double click on it in Toolbox or drag and drop the element

from Toolbox onto the form.

 

In the “Add Dataset” window select “Untyped dataset” and click the “OK” button.

Since we have no dataset schema available, we need to choose the Untyped dataset

as a structure in which we can keep information. (For additional information on dataset types

please refer to http://msdn.microsoft.com/en-us/library/8bw9ksd6%28v=vs.71%29.aspx.)


Select the dataSet1 component in the form editor. Select the Tables property

on the Property Grid and click the button to open the Tables Collection Editor.

Click the “Add” button to add a table. Set the TableName property and Name to “Products”.

Select the Columns property and click the button to open the Columns Collection Editor.

In Columns Collection Editor window click the “Add” button to add a new column to

your table. Set the ColumnName property to “ProductName”.

Close both editors.

Now right click on the form and select “View Code” option in the context menu

to display code window.

In order for the report to display the data you need to populate your data source.

You can use the LoadData function for this purpose.

public void LoadData()
        {
            DataRow row = products.NewRow();
            row["ProductName"] = "SharpShooter Reports.Win";
            products.Rows.Add(row);
            row = products.NewRow();
            row["ProductName"] = "SharpShooter Reports.Web";
            products.Rows.Add(row);
            row = products.NewRow();
            row["ProductName"] = "SharpShooter Reports.Silverlight";
            products.Rows.Add(row);
            row = products.NewRow();
            row["ProductName"] = "SharpShooter Reports.WPF";
            products.Rows.Add(row);
            row = products.NewRow();
            row["ProductName"] = "SharpShooter OLAP";
            products.Rows.Add(row);
            row = products.NewRow();
            row["ProductName"] = "SharpShooter Gauges";
            products.Rows.Add(row);
            row = products.NewRow();
            row["ProductName"] = "SharpShooter Dashboards";
            products.Rows.Add(row);
        }



The window displaying inserted code.

 

Step 3. Creating a Template

To get started on creating and using the report generator in your applications

you need to add ReportManager component onto the form. ReportManager is used for

storing report templates and has a wide range of report editing and report generation features.

To place ReportManager component, switch to the application form and add the ReportManager

element onto it from Toolbox by double clicking.

 

The component is displayed in the bottom part of the window.

Right click the ReportManager component and select Properties tab.

In the opened Properties window make sure the OwnerForm property is set to “Form1”.

Double click on the ReportManager component to open the ReportManager editor.

Go to the “Data sources” tab and click the “Add” button. Set the name of the data source to “Products”,

choose “dataSet1.Products” as data source value and click the “OK” button.

Next go to the “Reports” tab. Click the “Add” button and select the “InlineReportSlot” item.

(Note: the InlineReportSlot provides a template, serialized in the application code)

 

Click the “Run Designer” button to start Reports Designer.

To create a new empty template, choose the “New” item in the File menu.

 

Select the “Blank C# Report” item in the Wizards Gallery and click the “OK” button.

 

Go to the “Insert” tab and click the “DataBand” button.

Click on the template area to add DataBand element to the template.

 

Go to the DataBand “Format” contextual tab. Set the Data Source property to “Products”.

In the Data Sources section of the DataSources window select ProductName field,

then drag and drop it onto the DataBand.

The Detail section and the TextBox element are created automatically.

The TextBox’s Value binding property contains script for loading data.

 

Choose the TextBox element and set the desired appearance using controls in the “Home” tab.

Save the template and close Report Designer, then click “OK” to close ReportManager Editor.

Step 4. Adding a Report Viewer

To display the generated report we need to add a ReportViewer element to our form.

To do this, get back to your application form, open the Toolbox, find a ReportViewer element in

the SharpShooter Reports group and add it to the form by double clicking.

The report viewer is added to the form.

Switch to code view window to manually add code to the class constructor.

The code represents invocation of the data loading function, the report generation function

and initialization of the Source property of the viewer.

public Form1()
{
    InitializeComponent();
    LoadData();
    inlineReportSlot1.RenderDocument();
    reportViewer1.Source = inlineReportSlot1;
}



The window displaying inserted code.

Switch back to the application form and place two Button elements from

Common Controls group of Toolbox onto it.

Right click the Button element on the form and select Properties option to

open the Button Properties window.

Edit the Text property on the Property Grid.

Set the property to “Template” for one button and to “Report” for the second one.

 

  

Position the elements on the form as you prefer.

Create the Click event handlers for the buttons. Double click on the Button and add code

which launches report generation to the event handler. Use the following code:

private void button1_Click(object sender, EventArgs e)
{
   inlineReportSlot1.DesignTemplate();
}
private void button2_Click(object sender, EventArgs e)
{
   inlineReportSlot1.RenderDocument();
   reportViewer1.Source = inlineReportSlot1;
}


The window displaying inserted code.

Click the “Start Debugging” button on the Microsoft Visual Studio toolbar to run the application.

 

The generated report is displayed in the Report Viewer.

Licensing

If you purchased the license, you should log in to our site with your account to download the license key.

Proceed to the “Downloads” section.

 

You can find the license key for the product in the products’ list.

 

After the license key is downloaded, launch the License Manager from the Start menu

to activate the license. Note: The license manager should be run with administrative privileges

in order to be able to add data to Windows registry.

In case the License Manager doesn’t have sufficient privileges to access the Windows registry,

the following error can occur.

 

To add the license data to registry press the “Add from file” button and select the *. elic file.

Make sure the license activation process  has been completed and the license information is displayed

in the License Manager window. Press the “Close” button to quit License Manager.

If the license is not installed correctly or is deactivated, “Trial” pop-ups will appear during the work 

with the Perpetuum Software components informing the user about a trial period.
 

Additionally, the ‘unregistered version’ watermark will be displayed during the work in designer.

 

For information concerning licensing and solutions on possible issues, please refer

to the following knowledge base section: http://helpcenter.perpetuumsoft.com/KB/c71/using-licenses.aspx.

Downloading

You can obtain the latest version of SharpShooter Reports.Win from  

PerpetuumSoft downloads page: http://www.perpetuumsoft.com/Downloads.aspx?lang=en.

If you have any questions regarding SharpShooter Reports.Win, don’t hesitate to contact us at support@perpetuumsoft.com

Add Feedback