GroupHeaderBand.PrintAcrossBands Property
Gets or sets whether this band is printed as the background layer across all other bands that belong to the same group.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v24.1.dll
NuGet Package: DevExpress.Reporting.Core
Declaration
Property Value
Type | Description |
---|---|
Boolean | true if this band is printed as the background layer across all other bands that belong to the same group; otherwise, false. |
Remarks
The PrintAcrossBands property enables you to do the following:
Display continuous content side-by-side with bands that belong to the same group –– header, detail, and footer bands.
Create margins for the content to avoid overlapped elements.
Create a custom watermark for a group, if the XRWatermark control does not meet your needs.
Export to table formats (for instance, export to Excel spreadsheets) does not work correctly in this case. To disable export for controls in the cross-band content, set their CanPublish property to false.
If the cross-band content does not reach the group’s bottom, the content is not stretched nor repeated.
Display Cross-Band Content and Group Headers
Use one of the following methods:
- Add an outer GroupHeaderBand that includes cross-band content, and an inner GroupHeaderBand that includes group headers. Specify group field(s) in the outer band. Enable the outer band’s PrintAcrossBands property.
Add a GroupHeaderBand that includes cross-band content, and add a SubBand to the GroupHeaderBand. Place headers on the SubBand. Enable the GroupHeaderBand‘s PrintAcrossBands property.
As an alternative, place the cross-band content on the SubBand and enable the SubBand‘s PrintAcrossBands property to print the cross-band content below the GroupHeaderBand. Set the GroupHeaderBand‘s PrintAcrossBands property to false. See SubBand.PrintAcrossBands for details.
Tips and Limitations
The PrintAcrossBands
setting is ignored in the following situations:
- When the band’s RepeatEveryPage property is set to true.
- When a group contains a VerticalDetailBand instead of a DetailBand.
- When the GroupHeaderBand contains the XRSubreport control. Consider side-by-side XRSubreport controls instead.
The PrintAcrossBands
property is not available in the VerticalHeaderBand class.
End-User Designer - Set the PrintAcrossBands Property Value
Click the GroupHeaderBand‘s smart tag and check the Print Across Bands property.
The band’s icon indicates if the band is printed across other group bands:
PrintAcrossBands = false | PrintAcrossBands = true |
---|---|
Tip
See the Create a Report with Cross-Band Content and Populated Empty Space in the VS Report Designer topic for information on how you can use the PrintAcrossBands property to create a band that is printed across the report’s other content.
Runtime Example
The code sample below illustrates how to add content that shows group information (the Order ID) and is printed across the DetailBand and GroupFooterBand. The report is bound to the OrderDetailsExtended view from the sample Northwind database that ships with the XtraReports installation.
using System.Drawing;
using System.Drawing.Printing;
using DevExpress.Drawing;
using DevExpress.Drawing.Printing;
using DevExpress.XtraReports.UI;
using DevExpress.XtraPrinting;
// ...
public static XtraReport CreateReportWithGroupHeader() {
// Create an XtraReport instance.
XtraReport report = new XtraReport() {
Name = "Invoice",
DisplayName = "Invoice",
PaperKind = DXPaperKind.Letter,
Margins = new Margins(100, 100, 100, 100)
};
// Create a GroupHeader band.
GroupHeaderBand groupHeaderBand = new GroupHeaderBand() {
HeightF = 25,
PrintAcrossBands = true,
};
groupHeaderBand.GroupFields.Add(new GroupField("OrderID"));
// Create a Detail band for the report.
DetailBand detailBand = new DetailBand() {
HeightF = 25,
};
// Create a GroupFooter band.
GroupFooterBand groupFooterBand = new GroupFooterBand() {
HeightF = 25,
};
// Add the created bands to the report.
report.Bands.AddRange(new Band[] { groupHeaderBand, detailBand, groupFooterBand });
// Create report controls.
XRLabel lbOrderId = new XRLabel() {
Font = new Font("Tahoma", 16f, FontStyle.Bold),
TextAlignment = TextAlignment.TopCenter,
ForeColor = Color.White,
BackColor = Color.SteelBlue,
BoundsF = new RectangleF(0, 1, 200, 200),
TextFormatString = "Order ID: {0}",
};
XRLabel lbProductName = new XRLabel() {
Font = new Font("Tahoma", 10f, FontStyle.Regular),
BoundsF = new RectangleF(250, 0, 200, 25),
};
XRLabel lbQuantity = new XRLabel() {
TextAlignment = TextAlignment.MiddleRight,
Font = new Font("Tahoma", 10f, FontStyle.Regular),
BoundsF = new RectangleF(550, 0, 100, 25),
};
XRLabel lbUnitPrice = new XRLabel() {
TextAlignment = TextAlignment.MiddleRight,
Font = new Font("Tahoma", 10f, FontStyle.Regular),
BoundsF = new RectangleF(450, 0, 100, 25),
TextFormatString = "{0:$0.00}",
};
XRLabel lbTotal = new XRLabel() {
Font = new Font("Tahoma", 14f, FontStyle.Bold),
TextAlignment = TextAlignment.MiddleRight,
BoundsF = new RectangleF(450, 0, 200, 25),
TextFormatString = "Total: {0:$0.00}",
};
// Configure the controls' expression bindings and summary settings.
lbOrderId.ExpressionBindings.Add(new ExpressionBinding("Text", "[OrderID]"));
lbOrderId.Summary.Running = SummaryRunning.Group;
lbProductName.ExpressionBindings.Add(new ExpressionBinding("Text", "[ProductName]"));
lbQuantity.ExpressionBindings.Add(new ExpressionBinding("Text", "[Quantity]"));
lbUnitPrice.ExpressionBindings.Add(new ExpressionBinding("Text", "[UnitPrice]"));
lbTotal.ExpressionBindings.Add(new ExpressionBinding("Text", "sumSum([ExtendedPrice])"));
lbTotal.Summary.Running = SummaryRunning.Group;
// Add the created controls to the bands.
groupHeaderBand.Controls.Add(lbOrderId);
detailBand.Controls.AddRange(new XRControl[] { lbQuantity, lbProductName, lbUnitPrice });
groupFooterBand.Controls.Add(lbTotal);
// Return the resulting report.
return report;
}