Skip to main content
All docs
V25.1
  • BrickSelector.GetBricksByTag(Document, Object) Method

    A static method that returns an enumeration of visual bricks with the specified tag from a document.

    Namespace: DevExpress.XtraPrinting

    Assembly: DevExpress.Printing.v25.1.Core.dll

    NuGet Package: DevExpress.Printing.Core

    Declaration

    public static IEnumerable<VisualBrick> GetBricksByTag(
        Document document,
        object tag
    )

    Parameters

    Name Type Description
    document Document

    The document from which to return bricks.

    tag Object

    The tag value. A brick is returned if its tag value matches the specified value.

    Returns

    Type Description
    IEnumerable<VisualBrick>

    Bricks from the specified document.

    Remarks

    BrickSelector methods can be used to post-process a generated document. The basic idea is to first use the Tag property to tag controls on the report page, and then use the GetBricksByTag method to find bricks generated by tagged controls on the report page and adjust their size and position.

    For more information on document bricks, review the following help topic: Bricks.

    Example - Set Control Height to Maximum Cell Height in a Table

    The following code snippet uses BrickSelector to determine the maximum brick height of a table cell. Upon completion, it converts the height value to a ReportUnit unit and sets the height of the XRRichText report control. The document is then rebuilt from the updated report. The cells that should be measured are tagged with the ‘richTextCell’ value. ‘richTextCell’.

    using DevExpress.XtraPrinting;
    using DevExpress.XtraReports.UI;
    using System.Collections.Generic;
    // ...
    var report = new XtrReport1();
    report.CreateDocument();
    var bricks = BrickSelector.GetBricksByTag(report.PrintingSystem.Document, "richTextCell");
    float maxHeight = 0;
    foreach (VisualBrick b in bricks) {
        var brickHeight = b.Size.Height;
        if (brickHeight > maxHeight) {
            maxHeight = brickHeight;
        }
    }
    var heighInReportUnits = GraphicsUnitConverter.Convert(maxHeight, GraphicsDpi.Document, GraphicsDpi.HundredthsOfAnInch);
    var richTextCell = report.FindControl("xrRichText1", true) as XRControl;
    richTextCell.SizeF = new SizeF(richTextCell.WidthF, heighInReportUnits);
    report.CreateDocument();
    ReportPrintTool reportTool = new ReportPrintTool(report)
    reportTool.ShowRibbonPreviewDialog(); 
    
    See Also