FlexReport for .NET | ComponentOne
Fields / Custom Fields
In This Topic
    Custom Fields
    In This Topic

    You can create your own custom fields and add them to the Report Designer. Custom fields in FlexReport can be generated using the C1.Win.FlexReport.CustomFields assembly. This can be done only by registering the assembly in C1FlexReportDesigner.4.exe.settings.

    Custom fields group

    In the sub-topics, we explain various types of in-built and custom fields, their properties, and how to add them to your reports. Note that the database used for adding fields is C1NWind.mdb.

    Note: The custom fields can only be generated by registering the assembly in FlexReportDesigner (.NET4.0) and C1FlexReportDesigner.4.exe.settings. It would require the use of the 4.0 versions of the respective controls and scaling the application to 4.0 .NET framework.

    Map Custom Field

    FlexReport supports map fields using its extensible custom field architecture. In the following sections, you'll see how you to customize map fields in reports using the FlexReportDesigner application. The Map custom field uses three assemblies, C1.Win.FlexReport.CustomFields, C1.Win and C1.Win.Map, which should be in the same folder as the FlexReportDesigner app.

    To start using the Map custom field in the FlexReportDesigner application, complete the following steps:

    1. Run the C1FlexReportDesigner application.
    2. Confirm that the map icon is present in the C1FlexReportDesigner toolbar. If it is not included, you may need to add the following line to the <customfields> section of the C1FlexReportDesigner.4.5.2.exe.settings/C1FlexReportDesigner.4.8.exe.settings/C1FlexReportDesigner.6.exe.settings file:
      • For Framework 6 version
        HTML
        Copy Code
        <customfields>
            <item value="C1.Win.FlexReport.CustomFields.6;C1.Win.FlexReport.CustomFields.Map" />
        </customfields>
        
      • For Framework 4.8 version
        HTML
        Copy Code
        <customfields>
            <item value="C1.Win.FlexReport.CustomFields.4.8;C1.Win.FlexReport.CustomFields.Map" />
        </customfields>
        
      • For Framework 4.5.2 version
        HTML
        Copy Code
        <customfields>
            <item value="C1.Win.FlexReport.CustomFields.4.5.2;C1.Win.FlexReport.CustomFields.Map" />
        </customfields>
        

      You can find the C1FlexReportDesigner.4.5.2.exe.settings, C1FlexReportDesigner.4.8.exe.settings and C1FlexReportDesigner.6.exe.settings files at the following location:
      C:\Users\user_name\AppData\Roaming\C1Report\

      Note: The C1FlexReportDesigner.x.x.exe.settings file gets generated at the mentioned location only when the user first opens a report in the C1FlexReportDesigner and not at the time of installation of WinForms Edition.
    3. Create a new report or open an existing report. Refer the Report Creation for an example.
    4. Click the map icon and drag it onto your report to add a Map field.

    That's it! Now, you have successfully added a map field to your report.

    Note that if C1FlexReport definition contains map field and the report is generated asynchronously, the map field cannot be displayed in the FlexViewer control. As a workaround please set the C1FlexViewer.UseAsyncRendering property of FlexViewer to False.

    Map Custom Field Properties

    FlexReportDesigner allows you to set important properties of the Map custom field. The Properties tab on the left-hand side displays properties for custom map field, such as Layers, Tracking, Styles, Spatial Locations and Legends.

    Layers

    The main part of a map is the tile layer which provides raster graphics representing the Earth surface or part of it, and zero or more layers representing spatial data.

    The tile layer is specified by the TileSource property. It may be set to a VirtualEarth tile source (road, aerial, or hybrid). The tile source may be set to "none" in which case no tiles will be drawn on the map. This may be useful especially when other layers such as KML provide enough data for the map visualization.

    Note that unless the tile source is "none", the tiles are loaded from a network location when the report runs, which may slow things down considerably.

    Except for the tile layer, all other layers are contained in the Layers collection. Currently, three layer types are supported as described below:

    Tracking

    The map shown by a Map field can automatically center and zoom in on the data shown on the map. This behavior is determined by two factors:

    Styles

    Visual attributes of map elements are mostly defined by styles. There are several types of styles (point marker styles, line styles and KML item styles); the applicable type is determined by the context, such as points layers use point marker styles, lines layers use line styles, and so on. Usually a style may be specified as a data driven expression (so that the actual style depends on run time data), with a fallback style used by default. How style expressions are specified and evaluated is described next.

    The Map custom field contains 3 style collections:

    These styles are available to all layers defined on the Map, and also to other Map fields in the current report. The styles in each collection are addressable either by index or - preferably - by name (using the Name property). When a style expression evaluates to a string, that string is used to search for a matching style, first in the current map and if that fails, in all other maps on the current report (only matching type styles are searched; for example, only MarkerStyles collections are searched for a point marker style, and so on).

    Spatial Locations

    Points and lines layers provide two different ways to specify spatial locations for the data:

    Legends

    A map can have several associated legends, rendered within its bounds. To facilitate placing a legend outside the map's bounds, the legend can be associated with any map field in the report, so you can add an empty map field just to hold a legend describing another map.

    Legends are contained within the Legends collection of the Map field. To add a legend, add an item to that collection. The location of a legend within its map's bounds is determined by the LegendAlignment property. Orientation determines whether items within the legend are placed vertically (default) or horizontally. Several other properties allow to fine-tune the way the legend looks.

    Items within the legend are represented by the Items collection. That collection may be populated automatically with data from non-KML layers of the current map, if the Automatic property of the legend is set to True. In that case the Items collection cannot be edited. Otherwise, the legend items must be added manually.

    The following types of legend items are supported:

    Adding Map Fields

    Now that you familiar with the basics of the custom map field, let us see how to add a map field to a report depicting the summary of Employees, Suppliers, and Customers by City.

    Complete the following steps:

    1. Create the base report.

      Add a new report in the designer, with C1NWind.mdb as the data source, with the following SQL query:
      Customers and Suppliers by City

    2. Add the main map.

      You'll add the map to the report's header:

      • Make some room for the map by dragging the header's bottom edge down in the report designer.
      • Click on the Map custom field icon and drag it onto the header.
    3. Adjust the map's properties.

      Set the map's properties as follows (only non-defaults are shown here):

      • AutoCenter: False
      • AutoZoom: False
      • CenterLatitude: 10
      • CenterLongitude: 15
      • ShowScale: True
      • TileSource: VirtualEarthAerial
      • ZoomLevel: .55
    4. Add Layers.

      Click ellipsis button next to Layers collection to open LayerBase Collection Editor. Add Members 'Employees', Suppliers', and 'Customers', select the data source and set their marker style and map location properties.
      LayerBase Collection Editor

      Note that you need to add a data source every time before you add a member to the LayerBase Collection Editor as each member uses different data source.

      The design area looks like the following image:

      Design view

    5. Preview the report.

      Preview Maps in Designer

    SuperLabel Custom Field

    SuperLabel fields are used to insert HTML text in reports. FlexReport supports SuperLabel fields using its extensible custom field architecture. In the following sections, you'll see how you to customize SuperLabel fields in reports using the FlexReportDesigner application. The SuperLabel custom field uses three assemblies, C1.Win.FlexReport.CustomFields, C1.Win and C1.Win.SuperTooltip, which should be in the same folder as the FlexReportDesigner app.

    To start using the SuperLabel custom field in the FlexReportDesigner application, complete the following steps:

    1. Run the C1FlexReportDesigner application.
    2. Confirm that the SuperLabel icon is present in the C1FlexReportDesigner toolbar. If it is not included, you may need to add the following line to the <customfields> section of the C1FlexReportDesigner.x.x.exe.settings file:
      HTML
      Copy Code
      <customfields>
          <item value="C1.Win.FlexReport.CustomFields.x.x;C1.Win.FlexReport.CustomFields.SuperLabel" />
      </customfields>
      

      You can find the C1FlexReportDesigner.x.x.exe.settings file at the following location: C:\Users\user_name\AppData\Roaming\C1Report\

      Note: The C1FlexReportDesigner.x.x.exe.settings file gets generated at the mentioned location only when the user first opens a report in the C1FlexReportDesigner and not at the time of installation of WinForms Edition. 'x' in the filename and HTML fragment represents the framework version used.
    3. Create a new report or open an existing report. For the steps to create reports, see Report Creation for an example.
    4. Click the SuperLabel icon and drag it onto your report to add a SuperLabel field.

    You have successfully added a SuperLabel field to your report.

    Let's now add a SuperLabel field to the report created in Map Custom Field.

    1. Open the report.
    2. Set PageHeader's Visible property to True.
    3. Drop a SuperLabel field in the Page Header section of the report.
    4. From the Properties window, set Text property to the following text:
      SuperLabel.Text
      Copy Code
      <html><body><font>Customers and Suppliers by City</font></body></html>
      

      In the designer, SuperLabel field should now look as follows:

      SuperLabel custom field

    5. Preview the report:

      Preview SuperLabel custom field.

    Styling SuperLabel

    The FlexReportDesigner allows you to personalize the SuperLabel field by specifying styles similar to CSS, such as border, background color, and text color. The image below illustrates different styles applied to the SuperLabel field.

    flexreport-superlabel-colorhsl

    The following code snippet illustrates how to customize SuperLabel field by changing text color, text align, border style and width, and background color. Observe, that the text color red is set using the color attribute while blue color is applied through style attribute using color: hsl(), specifying Hue, Saturation and Lightness components.

    HTML
    Copy Code
    <html><body><h2 style="color: red; text-align:center; border-style: solid; border-width: 2px; background-color:beige;">Report on <span style="color:hsl(240,100%,50%);">Customers and Suppliers</span> by City</h2></body></html>