Showcase – Enhance End User Designer functionality in ActiveReports 6

The End User Designer which is a part of the professional edition of ActiveReports 6, allows you to host the report designer in your own Windows Forms applications and allow your end users to create and modify their own reports. You can find the article from our documentation – Basic End User Designer – with information about creating a basic End User Designer. This article is trying to showcase some additional functionalities – like adding a sub report without writing any code – that you add to your implementation of End User Designer.The good thing with ActiveReports is that it already provides samples demonstrating and talking about different functionality available in the product and End User Designer. A user can use all the report features in the End User Designer; however using a subreport in the End User Designer is a trivial task as there is no option to create multiple reports simultaneously.

In addition to this if we want to use a subreport in the End User Designer, then a lot of script code is required achieve the desired results. The complexity increases when working in the End User Designer as there is no option to create multiple reports simultaneously and the report layout for the subreport has to be saved on the disk to be used later. A typical code example can be found in the article – Script for Subreports – from our documentation.

In this article, I would like to present an enhanced version of the End User Designer (using the shipped sample) which allows creating and using subreports without writing a single line of code. This will enable us to save the report layouts in memory, which will be added to a list present in the toolbar. The image below will make it clearer:

Finally when we are done with the creation of report layouts for the subreport and drag a subreport control to the main report, we would have an option to select the subreport either from the list of reports which we added or specify it from a physical location. The next image will give some more idea about it:

Though it sounds pretty straightforward but there are lots of things which need to be considered when approaching it. Let us find out what it takes to achieve this functionality:

  1. The first step involves adding a combo box and a button to the End User Designer tool strip which we will use to save the report layouts in memory.
  2. Next steps involve adding two forms to the project which will act as a save dialog and the report selection dialog (once the reports are saved).
  3. Till now it sounds a pretty simple implementation but now starts the tricky part. First of all we need to check whether a control which is dropped in the main report is a Subreport and which section it has been dropped onto. The LayoutChanging event allows this check to be performed.
  4. If the condition in the previous step is true then the “Select Subreport” dialog box is popped up so that a report can be supplied to the control.
  5. We select a report and set it as a subreport, but there are many things which happen between selection and showing of the subreport. When a subreport is selected, a SubReportDataObject is created with three properties (subreport name, section name, and subreport data) where subreport data is the string form of the rpx file. Let me first make it clear that the RPX (report layout) file is an XML and we are using stream to save and load the report. The main issue which arises when saving the reports is that the XML tags are automatically modified and therefore we need to find some way to get it back to same pattern which an RPX file should have. This is mandatory else we would not be able to load the report in the subreport control.
  6. The reversion of the pattern to its original form has to be done via script and in the ReportStart event. We would not want to do this everytime we save and load a report, so the question is how to automate this process? To do this, we need to add a resource file to the project which contains two strings.:
    1. If ReportStart event is already present in the report script. This is required as it might be possible that a user has already written something to the script section of the main report.
    2. If ReportStart event is not present in the report script.
    3. Both these variables contain script code which is added to the main report automatically on the basis of the presence of the ReportStart event. The added script decodes the contents of the userdata and assigns the subreports accordingly.
  7. Now we should be able to display the subreport properly on preview; however there are still many conditions which have to be checked once a report is assigned to the subreport control. It is possible that a user moves the subreport to a different location/ section, renames the control, renames the section containing the subreport. All these changes have to be considered as well.

Once all the steps have been completed, we should be ready to use the design reports using subreports in the End User Designer. If it sounds too complex then you should take a look at the – Enhanced – End User Designer – sample application where I have demonstrated how to incorporate all the above mentioned steps. To make it clearer, I have divided the additional code (apart from the code which is already present in the shipped End User Designer sample) into different sections. I hope this would help users to design their reports quickly and effectively. The Video below will demonstrate its functionality.

2 thoughts on “Showcase – Enhance End User Designer functionality in ActiveReports 6

  1. This is exactly what I'm looking for,great article but I want to see the project.I cant reach the sample project,could you please refresh the link!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s