BACKGROUND


End User Designer is a very nice tool which allows a developer to provide his end users, the ability to create or edit reports and that too without the need of installing Visual Studio. Its simple implementation and deployment makes the complete operation pretty much hassle free. Again like all other features in ActiveReports, the EUD is flexible enough to incorporate the customizations a developer may want to implement. The purpose of this blog is to act as a repository for questions which may be related to achieving some specific results from the EUD or simply put, some customizations which a user may want.

In this blog, I have used the SectionReport as my preferred report since it is more code oriented as compared to RDL/Page Report. This does not mean that all these actions cannot be implemented for the latter; however using both would obviously take up more space and defeat the purpose of keeping this blog as short as possible. So let us straightaway move on to some simple but useful customization scenarios.

CUSTOMIZATIONS


Below are some of the customizations which can be applied to the End User Designer for some custom functionality:

  • Set Default Report type for the designer
    The default report type in the EUD is a Section Report. However we may want to set an RDL or a Page Report as the default report upon load. So we can use the following code to do this. The following screenshot shows the code with the possible options:
    ReportType


  • Determine the Drop Location of any control
    There might scenarios where you may want to get information about the location of the control as soon as it is dragged and dropped on to the designer. The DragDrop event comes to the rescue here. The code will look like this:
            private void reportDesigner_DragDrop(object sender, DragEventArgs e)
    {
    GrapeCity.ActiveReports.SectionReportModel.Section section = (GrapeCity.ActiveReports.SectionReportModel.Section)this.reportDesigner.SectionAt(new Point(e.X, e.Y));
    Point ptDesigner = this.reportDesigner.PointToClient(new Point(e.X, e.Y));
    Point ptSection = this.reportDesigner.PointToSection(section, ptDesigner);
    Graphics g = this.CreateGraphics();
    PointF ptControlLocation = new PointF(ptSection.X / g.DpiX, ptSection.Y / g.DpiY);
    MessageBox.Show(ptControlLocation.ToString());
    }

  • Disable Text Editing in any control
    Sometimes a developer would not want his end users to make any modifications to the control's text. So to achieve this functionality, we need to handle the EditModeEntering event of the designer. This will take care of the scenario when a user tries to double click on the control to enter the edit mode. However the user may also use the properties window to make modifications to the control' s text. To overcome this scenario, we need to handle the SelectionChanged event and disable the properties windows. Let's take a look at the code which performs both these operations.
            private void reportDesigner_EditModeEntering(object sender, EditModeEnteringEventArgs e)
    {
    var control = e.Control;
    if (control is SectionReportModel.Label)
    {
    e.Cancel = true;
    }
    }

    private void reportDesigner_SelectionChanged()
    {
    for (int i = 0; i < this.reportDesigner.Selection.Count; i++)
    {
    string ctl = this.reportDesigner.Selection[i].GetType().ToString();
    if (ctl == "GrapeCity.ActiveReports.SectionReportModel.Label")
    {
    reportPropertyGrid.Enabled = false;
    }
    else
    {
    reportPropertyGrid.Enabled = true;
    }
    }
    }


    This is how the disabled properties window will look like:

    PropWindow




  • Stop Deletion of any Control from the EUD
    This is one of the frequently asked question when it comes to working with EUD. That is how to stop the end user from deleting any particular control from the layout. Well to do this, we simply need to handle the LayoutChanging event of the designer and iterate through all the sections/controls of the report. Next we need to either stop or allow the deletion of the control according to the requirements. Please check the following code which allows deletion of all the controls but label.
            private void reportDesigner_LayoutChanging(object sender, LayoutChangingArgs e)
    {
    var report = (SectionReport)reportDesigner.Report;
    if (e.Type == LayoutChangeType.ControlDelete)
    {
    foreach (SectionReportModel.Section section in report.Sections)
    {
    foreach (SectionReportModel.ARControl control in section.Controls)
    {
    if (control.Name == e.Name)
    {
    if (control is SectionReportModel.Label)
    {
    e.AllowChange = true;
    }
    else
    {
    e.AllowChange = false;
    MessageBox.Show("You cannot delete any control except Label");
    }
    }
    }
    }
    }
    }


CONCLUSION


So we just checked out some quick customizations which can be implemented in the EUD. This list is not exhaustive since there could be many more scenarios which one may want to implement. Any such ideas/questions are welcome. A sample application showcasing all the above customizations can be downloaded from the link below.

Download Sample