PageHeaderBand.PrintAcrossBands Property
Gets or sets whether this band is printed as the background layer across all other bands that belong to the same page.
Namespace: DevExpress.XtraReports.UI
Assembly: DevExpress.XtraReports.v24.2.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 page; otherwise, false. |
Remarks
Enable the PrintAcrossBands property if you need to:
Arrange the band’s content side by side with the page’s content.
Provide margins for the content to avoid overlapped elements.
Create a custom page watermark, 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’s bottom if it exceeds the page height. If the cross-band content does not reach the page bottom, the content is not stretched nor repeated.
Display Cross-Band Content and Page Headers
Add a PageHeaderBand to a report, and a SubBand under the PageHeaderBand, if you need to display both cross-band content and page headers. Add cross-band content to the PageHeaderBand and enable the band’s PrintAcrossBands property. Place page headers on the SubBand.
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 PageHeaderBand. Set the PageHeaderBand‘s PrintAcrossBands property to false. See SubBand.PrintAcrossBands for details.
Set PrintAcrossBands in the Designer
Click the PageHeaderBand‘s smart tag and check the Print Across Bands property.
The band’s icon indicates if the band is printed across other 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 content that crosses the SubBand and DetailBand. The report is bound to the Products table 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 CreateReportWithPageHeader() {
// Create an XtraReport instance.
XtraReport report = new XtraReport() {
Name = "ProductList",
DisplayName = "Product List",
PaperKind = DXPaperKind.Letter,
Margins = new Margins(100, 100, 100, 100)
};
// Create a PageHeader band.
PageHeaderBand pageHeaderBand = new PageHeaderBand() {
HeightF = 25,
PrintAcrossBands = true,
};
// Create a SubBand under the PageHeader band.
SubBand subBand = new SubBand() {
HeightF = 25,
};
pageHeaderBand.SubBands.Add(subBand);
// Create a Detail band for the report.
DetailBand detailBand = new DetailBand() {
HeightF = 25,
};
// Add the created bands to the report.
report.Bands.AddRange(new Band[] { pageHeaderBand, detailBand });
// Create report controls.
XRLabel lbReportName = new XRLabel() {
Text = "Product Catalog",
Font = new Font("Tahoma", 16f, FontStyle.Bold),
TextAlignment = TextAlignment.TopCenter,
ForeColor = Color.White,
BackColor = Color.SteelBlue,
BoundsF = new RectangleF(0, 1, 200, 1100),
};
XRLabel lbProductName = new XRLabel() {
Font = new Font("Tahoma", 10f, FontStyle.Regular),
BoundsF = new RectangleF(250, 0, 300, 25),
};
XRLabel lbUnitPrice = new XRLabel() {
TextAlignment = TextAlignment.MiddleRight,
Font = new Font("Tahoma", 10f, FontStyle.Regular),
BoundsF = new RectangleF(550, 0, 100, 25),
TextFormatString = "{0:$0.00}",
};
XRLabel lbProductNameTitle = new XRLabel() {
Text = "Product Name",
Font = new Font("Tahoma", 10f, FontStyle.Bold),
BoundsF = new RectangleF(250, 0, 300, 25),
};
XRLabel lbUnitPriceTitle = new XRLabel() {
Text = "Unit Price",
TextAlignment = TextAlignment.MiddleRight,
Font = new Font("Tahoma", 10f, FontStyle.Bold),
BoundsF = new RectangleF(550, 0, 100, 25),
};
// Configure the controls' expression bindings.
lbProductName.ExpressionBindings.Add(new ExpressionBinding("Text", "[ProductName]"));
lbUnitPrice.ExpressionBindings.Add(new ExpressionBinding("Text", "[UnitPrice]"));
// Add the created controls to the bands.
pageHeaderBand.Controls.Add(lbReportName);
subBand.Controls.AddRange(new XRControl[] { lbProductNameTitle, lbUnitPriceTitle });
detailBand.Controls.AddRange(new XRControl[] { lbProductName, lbUnitPrice });
// Return the resulting report.
return report;
}