Skip to main content

Page.AddBrick(VisualBrick) Method

Adds the specified brick to the page.

Namespace: DevExpress.XtraPrinting

Assembly: DevExpress.Printing.v26.1.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;
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;
        }

    }
}

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.

See Also