Skip to main content

Create a Report with Cross-Band Content and Populated Empty Space in the VS Report Designer

  • 5 minutes to read

This tutorial describes how to create a report similar to the Cross-Band Content demo that includes the following layout options:

  • Print part of the content across bands (the blue panel).
  • Populate the empty space between the detail and footer information with blank rows.

You can view the online demo or view the desktop demo (requires the DevExpress Demo Center to be installed).

preview-6

Bind to Data

  1. Add a new blank report to your application.

  2. Bind the report to the OrderDetailsExtended view from the sample Northwind database. Join the following tables/views:

    • The OrderDetailsExtended view to the Orders table by the OrderID field.
    • The Orders table to the Customers table by the CustomerID field.
  3. Set the report’s DataMember to OrderDetailsExtended.

    set-data-member

Add a Data Table

  1. Expand the OrderDetailsExtended query in the Field List and select the ProductName, UnitPrice, Quantity, and ExtendedPrice fields. Hold CTRL or SHIFT and click the fields to select multiple fields and drop them onto the Detail band.

    drop-fields

    This creates an XRTable with each cell bound to a data field.

  2. Add line numbers. Right-click the ProductName cell and select Insert | Column to Left from the context menu.

    add-cell

  3. Select the new cell and specify the following property values:

    • Summary: Report
    • Expression: sumRecordNumber([ProductName])

    add-line-numbers

  4. Format the currency data. Click the UnitPrice cell’s smart tag and set Format String to {0:$0.00}. Set the ExtendedPrice cell’s format string to the same value.

    format-cells

The resulting report lists all items from all invoices.

preview-1

Group Data

Group table data by Order ID to produce invoices.

  1. Right-click the design surface. Select Insert Band / GroupHeader from the context menu.

    add-group-header

  2. Click the GroupFields property’s ellipsis button in the GroupHeader‘s smart tag to invoke the Group Field Collection Editor.

    invoke-group-editor

  3. Click the Add button to add a group field. Expand the FieldName property’s drop down and select OrderID from the list.

    create-group-field

  4. Correct the line numbers, as the records are now arranged in groups. Select the cell that displays line numbers and change the Summary property to Group.

    change-line-numbers

The GroupHeader band is printed for each group. Use it to add a heading that includes column titles, an invoice ID, and a date.

  1. Switch to the Field List and select the fields for which you want to create column titles. Drag the selected fields onto the GroupHeader band with the right mouse button.

    drop-titles

  2. Switch to the Field List, select the OrderID field, and drop it onto the band. Do the same with the OrderDate field.

    identify-invoice

  3. Add captions to the Order ID and OrderDate fields:

    • Click the OrderID label’s smart tag and set its Format String property to Order ID: {0}.

    • Click the OrderDate label’s smart tag and set its Format String to Order Date: {0:dddd, MMMM d, yyyy}.

    adjust-label-text

The records are now grouped by orders.

preview-2

Add Totals

Add a footer to display totals and other summary data on invoices.

  1. Right-click the design surface. Select Insert Band / GroupFooter from the context menu.

    add-group-footer

  2. Drop an XRTable from the Toolbox. Configure the table’s cells to display the following totals:

    Caption

    Format String

    Summary

    Expression

    Sub Total:

    {0:$0.00}

    Group

    sumSum([Quantity] * [UnitPrice])

    Discount:

    {0:$0.00}

    Group

    sumSum([UnitPrice] * [Discount] * [Quantity])

    Grand Total:

    {0:$0.00}

    Group

    sumSum([ExtendedPrice])

    format-totals

  3. Place each invoice on a separate page. Click the GroupFooter‘s smart tag and set the PageBreak property to AfterBand.

    align-footer

  4. Align the invoice totals to the bottom of the page. Click the GroupFooter‘s smart tag and check the PrintAtBottom property.

    align-footer

Each invoice is now placed on a separate page and the invoice totals are printed at the page bottom.

preview-3

Populate the Empty Space

Add empty lines to invoices to populate the empty space between the Detail band’s data and the totals.

Click the Detail band’s smart tag and check the FillEmptySpace property.

fill-empty-space

The empty region below the Detail band is populated with copies of the band. The band retains its layout, but report controls are printed without data. Their Text property values are displayed instead.

preview-4-0

Click each cell’s smart tag and clear the Text property to display empty lines.

clear-cell-text

preview-4

Add Cross-Band Data

Add a panel with recipient details across the entire invoice. Place the panel on a separate GroupHeader band that is printed in the background of other bands.

  1. Add another GroupHeader band to the top of the report. Click the added band’s smart tag and set the PrintAcrossBands property. This makes the band content start at the top of the GroupHeader1 and end at the bottom of the GroupFooter1 band.

    printundernextband

    Tip

    Choose PageHeaderBand instead of the GroupHeader band to limit the cross-band content to a page, even if the GroupFooter is on the next page.

  2. As the new GroupHeader band is above the invoice header, it is not grouped by orders. To include it in the grouping, remove the OrderID group field from the GroupHeader1 band, and add it to GroupHeader2.

  3. Add an XRPanel control to the GroupHeader. Specify the panel’s BackColor property and drop fields onto the panel.

    add-recipient

  4. Adjust the panel’s width and height. The height should match the page height, as the GroupFooter is printed at the bottom of the page.

    adjust-crossband-height

  5. Switch to Print Preview. The panel is printed on the background of the group content.

    preview-5

  6. Adjust the content in other bands to print it side-by-side with the panel.

    adjust-width

See the final report in Print Preview.

preview-6

Create a Report with Cross-Band Content and Populated Empty Space in the End-User Report Designer

Tutorials that explain how to create different reports in EUD Report Designers for WinForms and Web are included in the End-User Documentation online help section: