Search Results for

    Show / Hide Table of Contents

    Class RegisteredObjects

    Contains all registered report items such as objects, export filters, wizards.

    Inheritance
    System.Object
    RegisteredObjects
    Namespace: FastReport.Utils
    Assembly: FastReport.dll
    Syntax
    public static class RegisteredObjects
    Remarks

    Use this class to register own components, wizards, export filters or another items that need to be serialized to/from a report file.

    Examples
    // register own wizard
    RegisteredObjects.AddWizard(typeof(MyWizard), myWizBmp, "My Wizard", true);
    // register own export filter
    RegisteredObjects.AddExport(typeof(MyExport), "My Export");
    // register own report object
    RegisteredObjects.Add(typeof(MyObject), "ReportPage", myObjBmp, "My Object");

    Properties

    Assemblies

    Declaration
    public static List<Assembly> Assemblies { get; }
    Property Value
    Type Description
    System.Collections.Generic.List<System.Reflection.Assembly>

    DataConnections

    Root object for all registered DataConnections

    Declaration
    public static DataConnectionInfo DataConnections { get; }
    Property Value
    Type Description
    DataConnectionInfo

    Exports

    Root object for all registered exports.

    Declaration
    public static ObjectInfo Exports { get; }
    Property Value
    Type Description
    ObjectInfo

    Functions

    Root object for all registered functions.

    Declaration
    public static FunctionInfo Functions { get; }
    Property Value
    Type Description
    FunctionInfo

    Objects

    Root object for all registered objects.

    Declaration
    public static ObjectInfo Objects { get; }
    Property Value
    Type Description
    ObjectInfo

    Methods

    Add(Type, String, Bitmap, String, Int32, Boolean)

    Registers an object in the specified category with button's image, text, object's flags and multi-insert flag.

    Declaration
    public static void Add(Type obj, string category, Bitmap image, string text, int flags = 0, bool multiInsert = false)
    Parameters
    Type Name Description
    System.Type obj

    Type of object to register.

    System.String category

    Name of category to register in.

    System.Drawing.Bitmap image

    Image for object's button.

    System.String text

    Text for object's button.

    System.Int32 flags

    Integer value that will be passed to object's OnBeforeInsert method.

    System.Boolean multiInsert

    Specifies whether the object may be inserted several times until you select the "arrow" button or insert another object.

    Remarks

    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.

    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.

    To learn about flags, see the method.

    Examples
    // 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");

    Add(Type, String, Int32, Int32)

    Registers an object in the specified category.

    Declaration
    public static void Add(Type obj, string category, int imageIndex, int buttonIndex = -1)
    Parameters
    Type Name Description
    System.Type obj

    Type of object to register.

    System.String category

    Name of category to register in.

    System.Int32 imageIndex

    Index of image for object's button.

    System.Int32 buttonIndex

    Index of object's button in toolbar.

    AddCategory(String, Bitmap, String)

    Registers a category that may contain several report objects.

    Declaration
    public static void AddCategory(string name, Bitmap image, string text)
    Parameters
    Type Name Description
    System.String name

    Category name.

    System.Drawing.Bitmap image

    Image for category button.

    System.String text

    Text for category button.

    Remarks

    Category is a button on the "Objects" toolbar that shows context menu with nested items when you click it. Consider using categories if you register several report objects. It can save space on the "Objects" toolbar. For example, FastReport registers one category called "Shapes" that contains the LineObject and different types of ShapeObject.

    The name of category must starts either with "ReportPage," or "DialogPage," depending on what kind of controls do you need to regiter in this category: report objects or dialog controls. After the comma, specify the category name. So the full category name that you need to specify in the name parameter, must be something like this: "ReportPage,Shapes".

    When register an object inside a category, you must specify the full category name in the category parameter of the Add method.

    AddConnection(Type, String)

    Registers custom data connection.

    Declaration
    public static void AddConnection(Type obj, string text = "")
    Parameters
    Type Name Description
    System.Type obj

    Type of connection.

    System.String text

    Name of connection.

    Remarks

    The obj must be of DataConnectionBase type.

    Examples
    // register data connection
    RegisteredObjects.AddConnection(typeof(MyDataConnection), "My Data Connection");

    AddExport(Type, String)

    Obsolete. Use ExportsOptions api instead.

    Declaration
    [Obsolete]
    public static void AddExport(Type obj, string text)
    Parameters
    Type Name Description
    System.Type obj
    System.String text

    AddExport(Type, String, String, Bitmap)

    Obsolete. Use ExportsOptions api instead.

    Declaration
    [Obsolete]
    public static void AddExport(Type obj, string category, string text, Bitmap image = null)
    Parameters
    Type Name Description
    System.Type obj
    System.String category
    System.String text
    System.Drawing.Bitmap image

    AddExportCategory(String, String, Int32)

    Obsolete. Use ExportsOptions api instead.

    Declaration
    [Obsolete]
    public static void AddExportCategory(string name, string text, int imageIndex = -1)
    Parameters
    Type Name Description
    System.String name
    System.String text
    System.Int32 imageIndex

    AddFunction(MethodInfo, String)

    Adds a new function into the specified category.

    Declaration
    public static void AddFunction(MethodInfo function, string category)
    Parameters
    Type Name Description
    System.Reflection.MethodInfo function

    MethodInfo containing all necessary information about the function.

    System.String category

    The name of category to register the function in.

    Remarks

    Your function must be a static, public method of a public class.

    The following standard categories are registered by default:

    • "Math"
    • "Text"
    • "DateTime"
    • "Formatting"
    • "Conversion"
    • "ProgramFlow"
    You may use one of the standard categories, or create a new category by the AddFunctionCategory(String, String) method call.

    FastReport uses XML comments to display your function's description. To generate XML comments, enable it in your project's properties ("Project|Properties..." menu, "Build" tab, enable the "XML documentation file" checkbox).

    Examples

    The following example shows how to register own functions:

    public static class MyFunctions
    {
      /// <summary>
      /// Converts a specified string to uppercase.
      /// </summary>
      /// <param name="s">The string to convert.</param>
      /// <returns>A string in uppercase.</returns>
      public static string MyUpperCase(string s)
      {
        return s == null ? "" : s.ToUpper();
      }
    
      /// <summary>
      /// Returns the larger of two 32-bit signed integers. 
      /// </summary>
      /// <param name="val1">The first of two values to compare.</param>
      /// <param name="val2">The second of two values to compare.</param>
      /// <returns>Parameter val1 or val2, whichever is larger.</returns>
      public static int MyMaximum(int val1, int val2)
      {
        return Math.Max(val1, val2);
      }
    
      /// <summary>
      /// Returns the larger of two 64-bit signed integers. 
      /// </summary>
      /// <param name="val1">The first of two values to compare.</param>
      /// <param name="val2">The second of two values to compare.</param>
      /// <returns>Parameter val1 or val2, whichever is larger.</returns>
      public static long MyMaximum(long val1, long val2)
      {
        return Math.Max(val1, val2);
      }
    }
    
    // register a category
    RegisteredObjects.AddFunctionCategory("MyFuncs", "My Functions");
    
    // obtain MethodInfo for our functions
    Type myType = typeof(MyFunctions);
    MethodInfo myUpperCaseFunc = myType.GetMethod("MyUpperCase");
    MethodInfo myMaximumIntFunc = myType.GetMethod("MyMaximum", new Type[] { typeof(int), typeof(int) });
    MethodInfo myMaximumLongFunc = myType.GetMethod("MyMaximum", new Type[] { typeof(long), typeof(long) });
    
    // register simple function
    RegisteredObjects.AddFunction(myUpperCaseFunc, "MyFuncs");
    
    // register overridden functions
    RegisteredObjects.AddFunction(myMaximumIntFunc, "MyFuncs,MyMaximum");
    RegisteredObjects.AddFunction(myMaximumLongFunc, "MyFuncs,MyMaximum");

    AddFunctionCategory(String, String)

    Adds a new function category.

    Declaration
    public static void AddFunctionCategory(string category, string text)
    Parameters
    Type Name Description
    System.String category

    Short name of category.

    System.String text

    Display name of category.

    Remarks

    Short name is used to reference the category in the subsequent FastReport.Utils.RegisteredObjects.InternalAddFunction(System.Reflection.MethodInfo,System.String) method call. It may be any value, for example, "MyFuncs". Display name of category is displayed in the "Data" window. In may be, for example, "My Functions".

    The following standard categories are registered by default:

    • "Math"
    • "Text"
    • "DateTime"
    • "Formatting"
    • "Conversion"
    • "ProgramFlow"

    Examples

    This example shows how to register a new category:

    RegisteredObjects.AddFunctionCategory("MyFuncs", "My Functions");

    CreateFunctionsTree(Report, FunctionInfo, XmlItem)

    Declaration
    public static void CreateFunctionsTree(Report report, FunctionInfo rootItem, XmlItem rootNode)
    Parameters
    Type Name Description
    Report report
    FunctionInfo rootItem
    XmlItem rootNode

    FindConnection(Type)

    Declaration
    public static DataConnectionInfo FindConnection(Type type)
    Parameters
    Type Name Description
    System.Type type
    Returns
    Type Description
    DataConnectionInfo

    FindExport(Type)

    Declaration
    public static ObjectInfo FindExport(Type type)
    Parameters
    Type Name Description
    System.Type type
    Returns
    Type Description
    ObjectInfo

    FindObject(Type)

    Finds the registered object's info.

    Declaration
    public static ObjectInfo FindObject(Type type)
    Parameters
    Type Name Description
    System.Type type

    The type of object to find.

    Returns
    Type Description
    ObjectInfo

    The object's info.

    Remarks

    This method can be used to disable some objects, for example:

    RegisteredObjects.FindObject(typeof(PDFExport)).Enabled = false;

    GetMethod(Type, String, Boolean)

    Gets the method or null if method is not found

    Declaration
    public static Delegate GetMethod(Type type, string methodName, bool inheritance)
    Parameters
    Type Name Description
    System.Type type

    Type for method finding

    System.String methodName

    Name for method finfing

    System.Boolean inheritance

    Use True value for inheritance the method from base type, use false for get the method only from the this type

    Returns
    Type Description
    System.Delegate

    IsTypeRegistered(Type)

    Checks whether the specified type is registered already.

    Declaration
    public static bool IsTypeRegistered(Type obj)
    Parameters
    Type Name Description
    System.Type obj

    Type to check.

    Returns
    Type Description
    System.Boolean

    true if such type is registered.

    RegisterMethod(Type, String, Delegate)

    Register and override the method with method name in the type. For property use the property name and _Get or _Set suffix.

    Declaration
    public static void RegisterMethod(Type type, string methodName, Delegate method)
    Parameters
    Type Name Description
    System.Type type

    Type for registering method

    System.String methodName

    Name of method fir registering

    System.Delegate method

    Method for registering

    Remove(String, String, Int32)

    Remove an object or a category from the collection of objects based on its name and path.

    Declaration
    public static void Remove(string objectName, string objectPath, int flags = 0)
    Parameters
    Type Name Description
    System.String objectName

    The name of the object or category to be removed.

    System.String objectPath

    The path to the object or category.

    System.Int32 flags

    Flags used to identify the specific object to be removed, if multiple objects have the same name.

    Remove(Type, String)

    Remove an object from the collection of objects based on its type and category.

    Declaration
    public static void Remove(Type obj, string category)
    Parameters
    Type Name Description
    System.Type obj

    The type of the object to be removed.

    System.String category

    The category associated with the object type for removal.

    Back to top © 1998-2025 Copyright Fast Reports Inc.