corelibraries-devexpress-dot-xtraprinting-dot-page-dot-addbrick-x28-devexpress-dot-xtraprinting-dot-visualbrick-x29.md
Adds the specified brick to the page.
Namespace : DevExpress.XtraPrinting
Assembly : DevExpress.Printing.v25.2.Core.dll
NuGet Package : DevExpress.Printing.Core
public abstract void AddBrick(
VisualBrick brick
)
Public MustOverride Sub AddBrick(
brick As VisualBrick
)
| Name | Type | Description |
|---|---|---|
| brick | VisualBrick |
The brick to be added to the page.
|
Use this method to add a brick to a document’s page(s). The following code demonstrates how to use this method in the report’s AfterPrint event handler to add a label brick to all pages of a document:
using System;
using System.Drawing;
using DevExpress.XtraPrinting;
using DevExpress.Drawing;
namespace T457705 {
public partial class XtraReport1 : DevExpress.XtraReports.UI.XtraReport {
public XtraReport1() {
InitializeComponent();
}
private void XtraReport1_AfterPrint(object sender, EventArgs e) {
string text = "Developer Express Inc.";
DXFont font = new DXFont("Arial", 20f);
SizeF size = this.PrintingSystem.Graph.MeasureString(text, font);
size.Height = size.Height + 100;
size.Width = size.Width + 50;
foreach (Page page in this.Pages) {
LabelBrick labelBrick = CreateLabel(page, font, size, text);
page.AddBrick(labelBrick);
}
}
LabelBrick CreateLabel(Page page, DXFont font, SizeF size, string text) {
LabelBrick labelBrick = new LabelBrick() {
Angle = 90,
Font = font,
Text = text,
VertAlignment = DevExpress.Utils.VertAlignment.Center
};
PointF brickLocation = new PointF(page.MarginsF.Left / 5, page.Size.Height / 2);
SizeF brickSize = new SizeF(size.Height, size.Width);
labelBrick.Initialize(this.PrintingSystem, new RectangleF(brickLocation, brickSize));
return labelBrick;
}
}
}
Imports DevExpress.Utils
Imports DevExpress.XtraPrinting
Imports Devexpress.Drawing
Namespace T457705
Partial Public Class XtraReport1
Inherits DevExpress.XtraReports.UI.XtraReport
Public Sub New()
InitializeComponent()
End Sub
Private Sub XtraReport1_AfterPrint(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.AfterPrint
Dim brickText As String = "Developer Express Inc."
Dim brickFont As New DXFont("Arial", 20.0F)
Dim brickSize As SizeF = Me.PrintingSystem.Graph.MeasureString(brickText, brickFont)
brickSize.Height = brickSize.Height + 100
brickSize.Width = brickSize.Width + 50
For Each page As Page In Me.Pages
Dim labelBrick As LabelBrick = CreateLabel(page, brickFont, brickSize, brickText)
page.InnerBricks.Add(labelBrick)
Next page
End Sub
Private Function CreateLabel(ByVal page As Page, ByVal font As DXFont, ByVal size As SizeF, ByVal text As String) As LabelBrick
Dim labelBrick As New LabelBrick() With {
.Angle = 90,
.Font = font,
.Text = text,
.VertAlignment = VertAlignment.Center}
Dim brickLocation As New PointF(page.MarginsF.Left / 5, page.Size.Height / 2)
Dim brickSize As New SizeF(size.Height, size.Width)
labelBrick.Initialize(Me.PrintingSystem, New RectangleF(brickLocation, brickSize))
Return labelBrick
End Function
End Class
End Namespace
The brick is printed over other bricks if they occupy its position.
Note
This method does not work if you use the CachedReportSource/CachedReportSourceWeb component to create report documents.
View Example: Reporting for WinForms - Add Vertical Text to Page Margin
Tip
Review the Add Cross-Band Data help topic for information on how to print content behind report bands.
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the AddBrick(VisualBrick) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
reporting-winforms-add-vertical-brick/CS/T457705/XtraReport1.cs#L20
LabelBrick labelBrick = CreateLabel(page, font, size, text);
page.AddBrick(labelBrick);
}
See Also
Create a Report with Cross-Band Content and Populated Empty Space in the VS Report Designer