The requested page is not available for the requested platform. You are viewing the content for Default platform.

BestSizeEstimator.GetBoundsToFitText(String, BrickStyle, RectangleF, ReportUnit) Method

Gets boundaries that fit the specified text with the specified style and system of measurement, and reside within the specified initial boundaries.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v19.1.dll

Declaration

public static RectangleF GetBoundsToFitText(
    string text,
    BrickStyle style,
    RectangleF originalBounds,
    ReportUnit reportUnit
)
Public Shared Function GetBoundsToFitText(
    text As String,
    style As BrickStyle,
    originalBounds As RectangleF,
    reportUnit As ReportUnit
) As RectangleF

Parameters

Name Type Description
text String

A string that specifies the text that the resulting boundaries should fit.

style BrickStyle

A BrickStyle object that specifies a drawing style.

originalBounds RectangleF

A RectangleF structure specifying the initial boundaries.

reportUnit ReportUnit

A ReportUnit enumeration value that specifies the system of measurement.

Returns

Type Description
RectangleF

A RectangleF structure specifying the resulting boundaries.

Remarks

The GetBoundsToFitText method allows you to calculate the rectangle that fits the specified text taking into account the specified settings. The initial boundaries passed as a parameter are useful when you want to specify vertical and horizontal alignment for the target text and place this text within a required rectangle.

The code snippet below demonstrates how to use this method to find the optimal size to draw a LabelBrick using the BrickGraphics.DrawBrick method.

using DevExpress.XtraReports.UI;

// Prepare for creating a document.
printingSystem.Begin();
BrickGraphics gr = printingSystem.Graph;
gr.Modifier = BrickModifier.Detail;

// Create a new brick instance and specify its settings.
LabelBrick brick = new LabelBrick();
brick.Text = "Some text";
brick.HorzAlignment = DevExpress.Utils.HorzAlignment.Far;
brick.VertAlignment = DevExpress.Utils.VertAlignment.Bottom;
RectangleF originalRect = new RectangleF(0, 0, 50, 50);
RectangleF rect = BestSizeEstimator.GetBoundsToFitText(brick.Text, brick.Style, originalRect, ReportUnit.Pixels);
brick.Rect = rect;

gr.DrawBrick(brick);

// Finish creating the document.
printingSystem.End();

To perform the opposite operation (that is get the font size to fit the specified boundaries), call the BestSizeEstimator.GetFontToFitBounds method.

See Also