Skip to main content
A newer version of this page is available. .

Page.AddBrick(VisualBrick) Method

Adds the specified brick to the page.

Namespace: DevExpress.XtraPrinting

Assembly: DevExpress.Printing.v21.2.Core.dll

NuGet Package: DevExpress.Printing.Core

Declaration

public abstract void AddBrick(
    VisualBrick brick
)

Parameters

Name Type Description
brick VisualBrick

The brick to be added to the page.

Remarks

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.Drawing;
using DevExpress.XtraPrinting;
// ...
private void XtraReport1_AfterPrint(object sender, EventArgs e) {
    string text = "Developer Express Inc.";
    Font font = new Font("Arial", 12f, FontStyle.Bold);
    SizeF size = this.PrintingSystem.Graph.MeasureString(text, font);
    foreach(Page page in this.Pages) {
        LabelBrick labelBrick = CreateLabel(page, font, size, text);
        page.AddBrick(labelBrick);
    }
}

LabelBrick CreateLabel(Page page, Font font, SizeF size, string text) {
    LabelBrick labelBrick = new LabelBrick() { 
        Angle = 90, 
        Font = font, 
        Text = text
    };
    labelBrick.StringFormat.PrototypeKind = BrickStringFormatPrototypeKind.GenericTypographic;
    PointF brickLocation = new PointF(page.MarginsF.Left / 2, page.Size.Height / 2);
    SizeF brickSize = new SizeF(size.Height, size.Width);
    labelBrick.Initialize(this.PrintingSystem, new RectangleF(brickLocation, brickSize));
    return labelBrick;
}

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: How to add a brick with vertical text to the margin of each report page

See Also