Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

XRLabel.AutoWidth Property

Specifies whether or not the width of a label depends on its text.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v24.2.dll

NuGet Package: DevExpress.Reporting.Core

#Declaration

[DefaultValue(false)]
[SRCategory(ReportStringId.CatBehavior)]
public bool AutoWidth { get; set; }

#Property Value

Type Default Description
Boolean false

true to automatically adjust the width to accommodate the label text; otherwise, false.

#Remarks

Use the AutoWidth property to always print an XRLabel‘s text in full, without limiting it by control dimensions. This is often required if a label’s text is supplied from a data source and is not immediately available at Visual Studio design time (for example, if a label has been assigned a summary function).

When using this feature, consider the following.

  • The result of using this option depends on the XRControl.WordWrap property value.

    • if the WordWrap property is enabled, a label’s width can be only decreased;
    • if the WordWrap property is disabled, a label’s width can either be increased or decreased to best fit a label’s contents.
  • This option has no effect on the width or position of other report controls.
  • This option depends on the current horizontal alignment setting of a label (the XRControl.TextAlignment property value).

    The following image illustrates how the AutoWidth works when the TextAlignment property is set to “left”.

    label-auto-width-left-alignment

    The following image illustrates how the AutoWidth works when the TextAlignment property is set to “right”.

    label-auto-width-right-alignment

    The following image illustrates how the AutoWidth works when the TextAlignment property is set to “center”.

    label-auto-width-center-new

  • Report controls are converted to bricks in the printed document layout, and we cannot change the brick’s size after document creation. If you have an editable control, it is not possible to automatically change the control’s size according to new text in the printed document layout. The editable area cannot exceed the control’s original dimensions.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the AutoWidth property.

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.

See Also