Skip to main content

XRRichText.CanGrow Property

Gets or sets a value indicating whether the control’s height can grow in order to display the contents in their entirety.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v24.1.dll

NuGet Package: DevExpress.Reporting.Core

Declaration

[Browsable(true)]
public override bool CanGrow { get; set; }

Property Value

Type Description
Boolean

true if the control’s height can grow in order to display all its text; otherwise, false.

Remarks

When the CanGrow property is set to true, the control’s height will be automatically increased (if required) so that all the text it contains is displayed. If there are other controls below the current control, they will be moved down to prevent them from overlapping. Note that if a control overlaps the growing control by even one pixel, it will not be pushed down by the growing control.

Note

If the control’s XRControl.AnchorVertical property is set to VerticalAnchorStyles.Bottom or VerticalAnchorStyles.Both, the CanGrow and XRRichText.CanShrink property values are ignored, and don’t affect final height calculation for this control.

Example

The following code snippet creates the XRRichText object, specifies certain properties, and saves its contents to a file.

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

public XRRichText CreateXRRichText(){
    // Create a Rich Text Box control.
    XRRichText xrRichText1 = new XRRichText();

    // Set automatic height calculation,
    // and make the borders visible.
    xrRichText1.CanGrow = true;
    xrRichText1.CanShrink = true;         
    xrRichText1.Borders = DevExpress.XtraPrinting.BorderSide.All;

    // Add lines of text to the document.
    // The XRRichText control converts an array of strings into paragraphs.
    string[] boxLines = new String[3];
    boxLines[0] = "Line 1";
    boxLines[1] = "Line 2";
    boxLines[2] = "Line 3";
    xrRichText1.Lines = boxLines;

    // Export XRRichText contents to Microsoft Office Word OpenXml format (DOCX).
    xrRichText1.SaveFile("output.docx", XRRichTextStreamType.XmlText);

    return xrRichText1;
}
See Also