Skip to main content

DetailBand Class

The main report band used to display recurrent data records from a report’s data source. This band cannot be deleted from a report.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v23.2.dll

NuGet Package: DevExpress.Reporting.Core

Declaration

public class DetailBand :
    Band,
    IDrillDownNode,
    IDetailBand

Remarks

The DetailBand is a mandatory element of the report. When you create a new report from a template, the DetailBand band is added automatically. If you create a report in code, you should always add the DetailBand band.

Appearance Settings

Appearance properties specified for bands or panels propagate to child controls, even though they may not take effect for some report elements. An obvious example of this behavior is the DetailBand element, that has no visible border or background color, even though it passes appearance property settings to its child controls. Another example is the XRPageBreak control, that has the XRControl.BackColor property, but ignores its value during rendering.

Review the following help topic for more information: Appearance Properties.

If a report element has a style assigned to it, the priority of the properties defined by that style is determined by the StylePriority property. Note that if conditional formatting is involved, the appearance it defines has a higher priority.

A report band cannot render its background color. When you change the BackColor property of any band, background color of all controls in that band is changed instead. This happens because of the XtraReports styling concept. Background color for a band means the background color for all the controls it contains that do not have the BackColor property set.

To change the background color of the band, add the XRPanel control that occupies the entire band, and move all the controls on the band to that panel. Then change the background color of the XRPanel control.

Repetition

When a report is bound to a data source, and the DetailBand contains controls bound to that data, the band is printed as many times as there are records in the data source unless otherwise specified using the ReportPrintOptions.

If the XtraReportBase.DataMember property is not specified or is specified incorrectly, the DetailBand displays the first record of the data source as many times as there are data records.

To specify how many times the detail band should be printed with or without a data source assigned to the report, use the following properties:

ReportPrintOptions.BlankDetailCount
Specifies how many times the empty Detail band is repeated before printing the regular data.
ReportPrintOptions.BlankDetailCount
Specifies how many times the empty Detail band is repeated before printing the regular data.
ReportPrintOptions.DetailCountAtDesignTime
Specifies how many times the Detail band is printed in the Report Designer Preview.
ReportPrintOptions.DetailCountOnEmptyDataSource
Specifies how many times the Detail band should be printed when no data source is defined for the report.

Integrity and Nested Bands

To specify whether the band content can be split across several pages, use its Band.KeepTogether property.

To specify a multi-column layout, use the MultiColumn property.

To show extended data below each record displayed in the DetailBand, use the DetailReportBand band to create a master-detail report.

Tip

Although a report can only contain a single detail band, you can create any number of SubBand objects within a band.

Review the following help topics for more information:

Example

The following example demonstrates how to add a control to the DetailBand instance, and then add this band to a report.

using System.Drawing;
using DevExpress.XtraReports.UI;
// ...

// Create a report.
XtraReport rep = new XtraReport();

// Create a DetailBand instance.
DetailBand detail = new DetailBand();

// Create an XRLabel control.
XRLabel label = new XRLabel();

// Set its background color.
label.BackColor = Color.DarkGreen;

// Add the label to the Detail band.
detail.Controls.Add(label);

// Add the Detail band to the report.
rep.Bands.Add(detail);

// Show the report's print preview.
rep.ShowPreview();

Implements

See Also