Designer custom controls

Hello,

I would like to create my own controls for the FR report designer. From which base class I have to inherite, and how to register into designer?

In FR 4.x VCL there were base classes for visible controls, dialog controls etc. How is the FR.Net class hierarchy for this?



With best regards - Ulrich Groffy

Comments

  • edited 7:00PM
    Hello,

    FastReport.Net has similar classes. Typically you need to inherit from ReportComponentBase class and do the following:
    - define properties;
    - override Assign and Serialize methods to assign/store properties;
    - override Draw method to draw;
    - override GetData method to fill the object with data in run-time.

    I'm attaching a simplest CheckBox object source code.
  • edited 7:00PM
    AlexTZ wrote: »
    Hello,

    FastReport.Net has similar classes. Typically you need to inherit from ReportComponentBase class and do the following:
    - define properties;
    - override Assign and Serialize methods to assign/store properties;
    - override Draw method to draw;
    - override GetData method to fill the object with data in run-time.

    I'm attaching a simplest CheckBox object source code.

    Hello,

    thank you for sending me this sample code, but is it possible that the zip file is empty? I can't see anything inside the archive file(?)

    How to register the custom control in the designer?

    Best regards - Ulrich
  • edited 7:00PM
    There is something wrong with the attachment; second try.
  • edited 7:00PM
    To register an object, use the RegisteredObject.Add method:

    /// <summary>
    /// Registers an object in the specified category with button's image and text.
    /// </summary>
    /// <param name="obj">Type of object to register.</param>
    /// <param name="category">Name of category to register in.</param>
    /// <param name="image">Image for object's button.</param>
    /// <param name="text">Text for object's button.</param>
    /// <remarks>
    /// <para>You must specify either the page type name or existing category name in the category parameter.
    /// The report objects must be registered in the "ReportPage" category or custom category that is
    /// registered in the "ReportPage" as well. The dialog controls must be registered in the "DialogPage"
    /// category or custom category that is registered in the "DialogPage" as well.</para>
    /// <para>If you want to register an object that needs to be serialized, but you don't want
    /// to show it on the toolbar, pass empty string in the category parameter.
    /// </para>
    /// </remarks>
    /// <example>
    /// <code>
    /// // register the report object
    /// RegisteredObjects.Add(typeof(MyReportObject), "ReportPage", myReportObjectBmp, "My Report Object");
    /// // register the dialog control
    /// RegisteredObjects.Add(typeof(MyDialogControl), "DialogPage", myDialogControlBmp, "My Dialog Control");
    /// // add a category and register an object inside it
    /// RegisteredObjects.AddCategory("ReportPage,MyCategory", myCategoryBmp, "My Category");
    /// // register another report object in MyCategory
    /// RegisteredObjects.Add(typeof(MyReportObject), "ReportPage,MyCategory",
    /// anotherReportObjectBmp, "Another Report Object");
    /// </code>
    /// </example>

    public static void Add(Type obj, string category, Bitmap image, string text)
  • edited 7:00PM
    Hello,

    thank you - works so far.


    Best regards - Ulrich

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.