xtrareports-devexpress-dot-xtrareports-dot-ui-dot-groupheaderband-00d9a513.md
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.v25.2.dll
NuGet Package : DevExpress.Reporting.Core
[Browsable(true)]
public override bool PrintAcrossBands { get; set; }
<Browsable(True)>
Public Overrides Property PrintAcrossBands As Boolean
| 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.
|
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 a custom watermark for a group, if the XRWatermark control does not meet your needs.
If the cross-band content does not reach the group’s bottom, the content is not stretched nor repeated.
Use one of the following methods:
The PrintAcrossBands setting is ignored in the following situations:
The PrintAcrossBands property is not available in the VerticalHeaderBand class.
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.
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;
}
Imports System.Drawing
Imports System.Drawing.Printing
Imports DevExpress.Drawing
Imports DevExpress.Drawing.Printing
Imports DevExpress.XtraReports.UI
Imports DevExpress.XtraPrinting
' ...
Public Shared Function CreateReportWithGroupHeader() As XtraReport
' Create an XtraReport instance.
Dim report As New XtraReport() With {.Name = "Invoice", .DisplayName = "Invoice", .PaperKind = DXPaperKind.Letter, .Margins = New Margins(100, 100, 100, 100)}
' Create a GroupHeader band.
Dim groupHeaderBand As New GroupHeaderBand() With {.HeightF = 25, .PrintAcrossBands = True}
groupHeaderBand.GroupFields.Add(New GroupField("OrderID"))
' Create a Detail band for the report.
Dim detailBand As New DetailBand() With {.HeightF = 25}
' Create a GroupFooter band.
Dim groupFooterBand As New GroupFooterBand() With {.HeightF = 25}
' Add the created bands to the report.
report.Bands.AddRange(New Band() { groupHeaderBand, detailBand, groupFooterBand })
' Create report controls.
Dim lbOrderId As New XRLabel() With {
.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}"}
Dim lbProductName As New XRLabel() With {
.Font = New Font("Tahoma", 10F, FontStyle.Regular),
.BoundsF = New RectangleF(250, 0, 200, 25)}
Dim lbQuantity As New XRLabel() With {
.TextAlignment = TextAlignment.MiddleRight,
.Font = New Font("Tahoma", 10F, FontStyle.Regular),
.BoundsF = New RectangleF(550, 0, 100, 25)}
Dim lbUnitPrice As New XRLabel() With {
.TextAlignment = TextAlignment.MiddleRight,
.Font = New Font("Tahoma", 10F, FontStyle.Regular),
.BoundsF = New RectangleF(450, 0, 100, 25), .TextFormatString = "{0:$0.00}"}
Dim lbTotal As New XRLabel() With {
.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
End Function
See Also