Custom report template

Hello,

I would like to create my own report template. As described in an earlier post from 2009 this is only possible by creating the template by code. Is it possible to register this customer template in a way that I can choose this template by the designer [file - new] dialog?


Best regards - Ulrich

Comments

  • edited 1:14PM
    Hello,

    You may create own report wizards/templates and register them using the RegisteredObjects.AddWizard method.
  • edited 1:14PM
    AlexTZ wrote: »
    You may create own report wizards/templates and register them using the RegisteredObjects.AddWizard method.


    Hello,

    if I would like to create a new empty report. I created a class, derived from class Wizards.BlankReportWizard. I tried the following :

    public class CustTemplate : Wizards.BlankReportWizard
    {
    public override bool Run(Design.Designer designer)
    {
    ReportPage page = new ReportPage();
    page.CreateUniqueName();

    FastReport.ReportTitleBand titleband = new ReportTitleBand();
    titleband.CreateUniqueName();
    titleband.Height = Units.Centimeters * 5; ;
    page.Bands.Add(titleband);

    designer.Report.Pages.Add(page);

    return true;
    }
    }


    Registering the wizzard/template :

    RegisteredObjects.AddWizard(typeof(CustTemplate), new Bitmap(16,16), "Custom Report", false);


    I can select the new report template in the designer [File - New] Dialog, but nothing visible happens...

    What is the idea behind the Wizzard classes?


    Best regards - Ulrich





  • edited 1:14PM
    Hello,

    See the modified code below.
      public class CustTemplate : FastReport.Wizards.WizardBase
      {
    
        public override bool Run(Designer designer)
        {
          // this will create a report with single page containing several empty bands
          if (!designer.CreateEmptyReport())
            return false;
    
          // this code will add another report page
          Report report = designer.Report;
    
          ReportPage page = new ReportPage();
          report.Pages.Add(page);
          // call CreateUniqueName after the object is added to the report
          page.CreateUniqueName();
    
          FastReport.ReportTitleBand titleband = new ReportTitleBand();
          // do not add page bands like ReportTitle to the Bands collection, use page properties instead
          page.ReportTitle = titleband;
          titleband.Height = Units.Centimeters * 5;
          titleband.CreateUniqueName();
    
          // tell the designer to reflect changes
          designer.SetModified(null, "ChangeReport");
    
          return true;
        }
      }
    
  • edited 1:14PM
    Hello,

    its working so far, and basically I understood the differend Wizzard classes. One minor thing I recognized is, that the 16x16 bitmap I assigned to the custom wizzard/template during registration, is not visible in the designer [File - New] dialog

    Best regards - Ulrich
  • edited 1:14PM
    Hello,

    It will be fixed in the next build.

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.