The following items are available to use in the MindFusion.Reporting reports. The majority of the report items share two common properties: Location and Size - specifying the position of the element relative to its parent element, and its size respectively.
The page is the most fundamental element of a MindFusion.Reporting report. Pages in the report are represented by objects of the Page class. Each report can contain an arbitrary number of pages. The page itself can contain an arbitrary number of other report elements, such as labels and data ranges. When the report is processed by a call to its Run method, the pages can be split if the target space is insufficient to hold the processed page contents.
The most notable page properties are Background, Border and PageOrientation. The first two define the background and border of the page. The latter is used to specify the page orientation. If PageOrientation is set to Unspecified, the actual orientation of the page is determined by the defaultPageOrientation parameter passed to the Layout method of the Report class.
Each page can optionally contain a header and/or a footer. Headers are displayed on top of the page, while footers are displayed at the bottom. If a page is split during report processing, its header and footer are displayed for each occurrence of the page in the final layout. You can assign a header and/or a footer to a page either through the report designer (see Report Designer) or through code. The latter requires you to assign a PageSection object to the Header or Footer property of the Page respectively. The following code illustrates this:
C# Copy Code |
---|
// Create the header |
VB.NET Copy Code |
---|
' Create the header |
There are various properties, such as Border, Background and Visible, which affect the visualization of the header and footer in the final layout.
The label elements display text within a report. Labels are represented by the Label class. The text displayed by the label can be either static, a value from a data source or a value calculated by an expression. Additionally, the text can contain various formatting specifiers, such as <b>, <i> and so on. The text displayed by a label is specified through its Text property.
Data-bound labels can be created only within DataRange objects. The data source of the label is specified by the DataSource property of its containing DataRange object. The name of the data field that the label is bound to is specified through the DataField property. When DataField is set, the Text property of the label is ignored and the displayed text is determined by the value of the related field in the data source.
Labels can display texts more complex than static and data field values. You can include the so-called expressions within the text of the label. When the text is processed, the expressions within it are evaluated and the expressions are replaced with the result of the evaluation.
To embed expressions in the label text enclose the expressions in square brackets. For example, the following label text is valid and it will display the string "Date: " followed by the system's date at the time of evaluation. Note, that the expression in the example is highlighted in bold.
Expression Copy Code |
---|
Date: [Now()] |
The result of the evaluation of the above text will be something similar to "Date: 12/10/2008 2:23:38 PM".
It is possible to specify formatting to the value of the expression. To do so, add an '@' symbol after the expression but before the closing ']' then add the string representing the formatting specifier enclosed in quotes. The following example extends the previous one by adding formatting to the resulting date. Note, that the formatting specifier in the example is highlighted in bold.
Expression Copy Code |
---|
Date: [Now()@"d"] |
The result of the evaluation will now be similar to the following: "Date: 12/10/2008".
For more information about the expressions in MindFusion.Reporting in general, visit Expressions. For more information on how to use expressions in label texts, check Using Expressions in Reports.
Besides the Text and the DataField properties, labels expose several other properties that can be used to further customize the appearance of the label text. The Alignment, LineAlignment, Padding, Color and Font control how the text of the label is displayed and the position within the label's bounds.
The data range elements provide a way to perform data-binding in MindFusion.Reporting reports. The data ranges are represented by the DataRange class. For extensive information about how to data-bind using data ranges can be found in the Binding Reports to a Data Source topic.
DataRange objects expose some common visualization properties, such as Background and Border. There are two additional properties - AlternatingBackground and AlternatingBorder, both of which default to null (Nothing in Visual Basic). When these properties are assigned values different from null, they are used as the background and border of every second occurrence of this data range in the final layout. In other words, Background and Border are used for the odd occurrences of a data range, while AlternatingBackground and AlternatingBorder are used for the even ones.
The AllowSplit property, when set to false, prevents the data range from splitting to more than one page when the report is processed. The ArrangeByX property specifies whether to lay out data range instances horizontally first, then vertically. If ArrangeByX is set to false (the default), the instances of the data range are always arranged vertically regardless of whether there is space along the x-axis. The Repeat property is used with disconnected data ranges to specify the number of occurrences of these data ranges in the final layout.
The picture elements enable you to add static images to a report. Pictures are represented by the Picture class. Similarly to labels, pictures can be data-bound if they are positioned within a data-bound DataRange element. To bind a picture to a field in the data source, use its DataField property.
To assign a static image to a picture, use the Image property. The border and background of the image can be specified through the Border and Background properties respectively. You can rotate the image at arbitrary degrees through the RotationAngle property. The alignment of the displayed image is controlled through the ImageAlign property.
The canvas elements can be used in order to perform custom rendering within a report. The canvas elements are represented by the Canvas class. In order to perform drawing within the canvas, you need to handle its RenderContents event. The DrawCanvasEventArgs argument passed to the handler of this event contains an IGraphics object, which can be used to perform the necessary drawing.
You can data-bind canvases in the same way you can bind labels and pictures - by placing them within a data-bound DataRange and setting the appropriate value to its DataField property. The value acquired through the data-binding is supplied to the RenderContents event handler through the DataValue property of the event argument.
MindFusion.Reporting provides four chart types that can be used in reports. They are represented by the BarChart, LineChart, PieChart and RadarChart classes. Each of these classes provides a set of properties that lets you customize the chart's appearance. For further information, read the topics of the respective classes. For more information on how to use charts in reports, visit Charts in Reports.
The page break elements are a special kind of report elements represented by the PageBreak class. Page breaks do not appear in the final layout of the report. When a page break is encountered during layout, it forces (as its name suggests) a new page to be created and the layout to continue on this new page. Page breaks should not be placed in containers other than pages or they may cause unpredictable results.
The only notable property of a PageBreak object is its position within its containing element specified by the Location property.
The line elements enable you to add straight colored lines to a report. Lines are represented by the Line class.
The Line objects expose two properties that define the position of the line relative to its containing element - StartPoint and EndPoint. The appearance of the line can be modified through the Color, DashStyle and Width properties.
The Ellipse elements are similar to the line - they enable you to add a static shape, an ellipse to a report.
To modify the appearance of the ellipse, use the Color, DashStyle and Width properties.