SubBand.PrintAcrossBands Property
Gets or sets whether the SubBand is printed as a background layer across a page or a group.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v24.1.dll
NuGet Package: DevExpress.Reporting.Core
Declaration
Property Value
Type | Description |
---|---|
Boolean | true, if the SubBand is printed as a background layer across a page or a group; otherwise, false. |
Remarks
Add a SubBand to a PageFooterBand or GroupFooterBand, and enable the SubBand‘s PrintAcrossBands property, in the following cases:
Display page or group header first, then cross-band content side-by-side with the rest of group or page content. Place the cross-band content on the SubBand to print the cross-band content after the parent band.
See PageHeaderBand.PrintAcrossBands and GroupHeaderBand.PrintAcrossBands to learn how to start cross-band content side-by-side with group or page header.
Create a custom watermark across pages or groups, if the XRWatermark control does not cover your needs.
Export into table formats (for instance, export into Excel spreadsheets) does not work correctly in this case. To disable export for the controls in the cross-band content, set their CanPublish property to false.
The cross-band content is cut off at the page bottom if it exceeds the page height, and the SubBand is child to a PageHeaderBand. If the cross-band content does not reach the group/page bottom, the content is not stretched nor repeated.
Set PrintAcrossBands in the Designer
Click the SubBand‘s smart tag and check the Print Across Bands property.
The SubBand‘s icon indicates if the band is printed across the group/page 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 a SubBand to a a GroupHeaderBand and place cross-band content in the SubBand. The report is bound to the Invoices view from the sample Northwind database that is shipped 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 CreateReportWithSubBand() {
// Create an XtraReport instance.
XtraReport report = new XtraReport() {
Name = "Invoices",
DisplayName = "Invoices",
PaperKind = DXPaperKind.Letter,
Margins = new Margins(100, 100, 100, 100)
};
// Create a GroupHeader band.
GroupHeaderBand groupHeaderBand = new GroupHeaderBand() {
HeightF = 25,
};
groupHeaderBand.GroupFields.Add(new GroupField("OrderID"));
// Create a SubBand under the GroupHeader band.
SubBand subBand = new SubBand() {
HeightF = 25,
PrintAcrossBands = true,
};
groupHeaderBand.SubBands.Add(subBand);
// 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,
BackColor = Color.LightGray,
BoundsF = new RectangleF(0, 1, 650, 50),
TextFormatString = "Order ID: {0}",
};
XRLabel lbCustomerName = new XRLabel() {
Font = new Font("Tahoma", 14f, FontStyle.Bold),
TextAlignment = TextAlignment.TopCenter,
ForeColor = Color.White,
BackColor = Color.SteelBlue,
BoundsF = new RectangleF(0, 1, 200, 200),
TextFormatString = "To: {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]"));
lbCustomerName.ExpressionBindings.Add(new ExpressionBinding("Text", "[ShipName]"));
lbProductName.ExpressionBindings.Add(new ExpressionBinding("Text", "[ProductName]"));
lbUnitPrice.ExpressionBindings.Add(new ExpressionBinding("Text", "[UnitPrice]"));
lbTotal.Summary.Running = SummaryRunning.Group;
lbTotal.ExpressionBindings.Add(new ExpressionBinding("Text", "sumSum([ExtendedPrice])"));
// Add the created controls to the bands.
groupHeaderBand.Controls.Add(lbOrderId);
subBand.Controls.AddRange(new XRControl[] { lbCustomerName });
detailBand.Controls.AddRange(new XRControl[] { lbProductName, lbUnitPrice, lbQuantity });
groupFooterBand.Controls.Add(lbTotal);
// Return the resulting report.
return report;
}