Skip to main content

XRControl.CanShrink Property

Gets or sets a value indicating whether the control’s height can decrease if its contents do not completely fill the control.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v21.2.dll


public virtual bool CanShrink { get; set; }

Property Value

Type Default Description


true, if the control’s height can decrease in order to remove unused space; otherwise, false.


When the CanShrink property is enabled, the control’s height can automatically decrease to the amount of its contents. All other report elements that may reside below the current control will be pushed up, to avoid blank space.

If a control already overlaps the shrinking control even by one pixel, it will not be pushed up by the shrinking control.

The XRControl.CanGrow and CanShrink property values are ignored if the XRControl.AnchorVertical property is set to VerticalAnchorStyles.Bottom or VerticalAnchorStyles.Both.

A control’s borders remain visible while its contents are shrunk if the CanShrink property is enabled and the XRControl.Text property value equals Empty. To hide the control along with its borders, set its XRControl.ProcessNullValues or XRControl.ProcessDuplicates property to ValueSuppressType.SuppressAndShrink.

Not all descendants of the XRControl class use the CanShrink property. For example, the Band class descendants ignore the CanShrink property.


The code sample below illustrates how to create an XRLabel object and bind it to data. You should bind your report to the Northwind database’s Products table for this example to work properly.

To learn about the events available for a report and its controls, see Report Events.

using System;
using System.Drawing;
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
// ...

public partial class XtraReport1 : XtraReport {

    public XRLabel CreateXRLabel() {
        // Create a new label object.
        XRLabel label = new XRLabel();

        // Bind the label to the UnitPrice data field. 
        // Change the label's foreground color depending on the UnitPrice data field value.
        label.ExpressionBindings.AddRange(new ExpressionBinding[] {
        new ExpressionBinding("BeforePrint", "Text", "[UnitPrice]"),
        new ExpressionBinding("BeforePrint", "ForeColor", "Iif([UnitPrice]>20, \'Red\', \'Green\')")});

        // Apply a currency format to the label's text.
        label.TextFormatString = "{0:c2}";

        // Automatically adjust the label's width to its content.
        label.AutoWidth = true;

        // Align the label's text to the bottom right corner.
        label.TextAlignment = TextAlignment.BottomRight;

        return label;

    public XtraReport1() {
        // ...
        // Add the label to the report's Detail band.
        XRLabel label = CreateXRLabel();
See Also