ActiveReports 18 .NET Edition
Report Authors: Designer Components / Report Controls / Section Report / TextBox
In This Topic
    In This Topic

    The TextBox control is the basis of reporting as it is used to display textual data in section reports. You can add multiple lines, wrap text to the control size, shrink text to fit within the bounds of control, and perform basic formatting.

    The TextBox control can be bound to any data or set at run time. Also, it is the same control that forms when you drag a field onto a report from the Report Explorer. In the Text property of the TextBox, you can enter static text or an expression. To enter a text directly into the TextBox, just double-click inside the control on the design surface of the report. An expression in TextBox can display fields from a database, calculate a value, or visually display data.

    Note: There is a difference in how the text is rendered in the CrossPlatform and in the GDI compatibility modes. Some text in the CrossPlatform mode (for example, text without spacing, text with non-ASCII characters, etc.) may not appear correctly in the report preview. For the correct text rendering, you must manually update the report layout (for example, change the control's size).

    Edit Mode

    You can double-click in the TextBox control to enter edit mode and enter text directly in the control, or you can enter text in the Properties window or code through the Text property.

    TextBox control in Edit Mode

    You can format text in the TextBox control in edit mode using the ActiveReports toolbar, or you can modify properties in the Properties window. Formats apply to all of the text in the control. Text formatting changes in the Properties window immediately appear in the control, and changes made in the toolbar are immediately reflected in the Properties window.

    Note: The TextBox and Label controls, unlike ReportInfo control, do not support page-related expressions.

    Important Properties

    Clicking the TextBox control reveals its properties in the Properties window.

    Property Description
    CanGrow Determines whether ActiveReports should increase the height of the control based on its content.
    CanShrink Determines whether ActiveReports should decrease the height of the control based on its value.
    CharacterSpacing Gets or sets a character spacing in points.
    CountNullValues Boolean which determines whether DBNull values should be included as zeroes in summary fields.
    Culture Gets or sets CultureInfo used for value output formatting.
    DataField Gets or sets the field name from the data source to bind to the control.
    DistinctField Gets or sets the name of the data field used in a distinct summary function.
    HyperLink Gets or sets the hyperlink for the text control.
    LineSpacing Gets or sets a line spacing in points.
    MinCondenseRate Specifies the minimal rate of the text horizontal scaling in percentages. Should be between 10 and 100.

    Gets or sets a value indicating whether this is a multi-line textbox control.

    OutputFormat Gets or sets the mask string used to format the Value property before placing it in the Text property.
    ShrinkToFit Determines whether ActiveReports decreases the font size when text values exceed available space.
    Style  Gets or sets a style string for the textbox.
    SummaryFunc Gets or sets the summary function type used to process the DataField Values.
    SummaryGroup Gets or sets the name of the group header section that is used to reset the summary value when calculating subtotals.
    SummaryRunning Gets or sets a value that determines whether that data field summary value will be accumulated or reset for each level (detail, group, or page).
    SummaryType Gets or sets a value that determines the summary type to be performed.
    Text Gets or sets the formatted text value to be rendered in the control.
    TextJustify Specifies text justification with TextAlign set to Justify.
    VerticalAlignment Gets or sets the position of the textbox's text vertically within the bounds of the control.
    VerticalText Gets or sets whether to render text according to vertical layout rules.
    WrapMode Indicates whether a multi-line textbox control automatically wraps words or characters to the beginning of the next line when necessary.

    TextBox Dialog Properties

    You can set the TextBox properties in the TextBox dialog. To open it, with the TextBox selected on the report, under the Properties window, click the Property dialog link.

    Name: Enter a name for the textbox that is unique within the report. This name is displayed in the Document Outline and in XML exports. You can only use underscore (_) as a special character in the Name field. Other special characters such as period (.), space ( ), forward slash (/), back slash (\), exclamation (!), and hyphen (-) are not supported.

    Tag: Enter a string that you want to persist with the control. If you access this property in code, it is an object, but in the Properties window or Property dialog, it is a string.

    Visible: Clear this check box to hide the control.

    DataField: Select a field from the data source to bind to the control.

    Text: Enter static text to show in the textbox. If you specify a DataField value, this property is ignored.

    HyperLink: Enter a URL to use in the Viewer HyperLink event. The URL automatically converts to an anchor tag or hyperlink in PDF and HTML exports.

    Background Color: Select a color to use for the background of the textbox.

    Name: Select a font family name or a theme font.

    Size: Choose the size in points for the font.

    Style: Choose Normal or Italic.

    Weight: Choose from Normal or Bold.

    Color: Choose a color to use for the text.

    Decoration: Select check boxes for Underline and Strikeout.

    GDI Charset: Enter a value to indicate the GDI character set to use. For a list of valid values, see MSDN Font.GDICharSet Property.

    GDI Vertical: Select this checkbox to indicate that the font is derived from a GDI vertical font.

    Line Spacing: This property sets the space between lines of text.

    Character Spacing: This property sets the space between characters.

    Multiline: Select this check box to allow text to render on multiple lines within the control.

    Textbox height

    Can increase to accommodate contents: Select this check box to set CanGrow to True.

    Can decrease to accommodate contents: Select this check box to set CanShrink to True.

    Can shrink text to fit fixed size control: Select this check box to set ShrinkToFit to True.

    Minimal rate of text horizontal shrinking (in %): Specify the percentage to which the text should be shrunk horizontally.

    Text direction

    RightToLeft: Select this check box to reverse the text direction.

    Vertical text: Select this check box for top to bottom text. 

    Vertical alignment: Choose Top, Middle, or Bottom.

    Horizontal alignment: Choose Left, Center, Right, or Justify.

    Justify method: Choose Auto, Distribute, or DistributeAllLines.

    Wrap mode: Choose NoWrap, WordWrap, or CharWrap to select whether to wrap words or characters to the next line.

    Note: You must select Justify in the Horizontal alignment property to enable the Justification method property options.


    • Top: Set the top padding in points.
    • Left: Set the left padding in points.
    • Right: Set the right padding in points.
    • Bottom: Set the bottom padding in points.

    SummaryFunc: Select a type of summary function to use if you set the SummaryRunning and SummaryType properties to a value other than None. For descriptions of the available functions, see the SummaryFunc enumeration.

    SummaryGroup: Select a section group that you have added to the report. If you also set the SummaryRunning property to Group, the textbox summarizes only the values for that group.

    SummaryRunning: Select None, Group, or All. If None, the textbox shows the value for each record. If Group, the textbox summarizes the value for the selected SummaryGroup. If All, the textbox summarizes the value for the entire report.

    SummaryType: Select the type of summary to use. For descriptions of the available types, see the SummaryType enumeration.

    Distinct Field: Select a field to use with one of the SummaryFunc distinct enumerated values.

    Count null values: Select this check box to include null values as zeroes in summary fields.

    Text Justification

    The TextJustify property of a Textbox control provides you justification options for aligning your text within a control. It is important to note that the Alignment property must be set to Justify for TextJustify property to affect the text layout.

    Note: The TextJustify property is also available in the Label control.

    You can choose from the following values of the TextJustify property:


    Results in Standard MSWord like justification where space at the end of a line is spread across other words in that line. This is the default value.


    Spaces individual characters within a word, except for the last line.


    Spaces individual characters within words and also sets the justification on the last line according to the length of other lines.

    To set text justification,

    1. Select the TextBox control to view its properties in the  Properties window.
    2. In the Properties window, set the Alignment to Justify.
    3. Go to the TextJustify property and from the drop down list select any one option.

    Text justification is supported when you preview a report in the Viewer, print a report, or export a report in PDF, and TIFF formats.

    Shrink Text to Fit in a Control

    When working with the TextBox or Label control in a Section report, you can use the ShrinkToFit property to reduce the size of the text so that it fits within the bounds of the control. The text shrinks at run time, so you can see the reduced font size when you preview, print or export the report.

    You can use other text formatting properties in combination with the ShrinkToFit property.


    • When both CanGrow and ShrinkToFit are set to True, CanGrow setting is ignored and only ShrinkToFit is applied.
    • When  ShrinkToFit is set to True and Angle is set to a value other than 0, the ShrinkToFit property is ignored.
    • ShrinkToFit property does not work in the following conditions:
      • VerticalText property is set for a control.
      • Multiline property is set to False.

    On exporting a report, various file formats handle ShrinkToFit differently. ShrinkToFit gets exported in all formats except Text.

    Multiline in TextBox

    You can display multiline text in TextBox and some other controls such as RichTextBox and Label for section reports.

    In a Section report, you can enable multiline display in your report control by setting the Multiline property to True. Then, with your control in edit mode, insert line breaks at the desired location using the Enter key or Ctrl + Enter keys to create multiline text. However, when the MultiLine property is set to False, the text entered into the control is displayed on a single line.

    Note: In edit mode, scrollbars appear automatically to fit multiline content within a control. However, these are not displayed at preview, so you may need to adjust the Size property of the control to display all of the text.

    Line Spacing and Character Spacing

    In edit mode, scrollbars appear automatically to fit multiline content within a control. However, these are not displayed at preview, so you may need to adjust the Size property of the control to display all of the text.

    TextBox line and character spacing

    To set Line or Character spacing,

    1. On the design surface, click the TextBox control to display it in the Properties window.
    2. In the Properties window, click the Property dialog command at the bottom to open the control dialog.
    3. In the TextBox dialog, go to the Format page and set the Line Spacing or Character Spacing values in points.

    Line and character spacing are supported when you preview a report, print a report, or export a Section report in HTML , PDF, and TIFF formats.

    Keyboard Shortcuts

    In the edit mode, you can use the following keyboard shortcuts.

    Key Combination Action
    Enter New line.
    Alt + Enter Saves modifications and exits edit mode.
    Esc Cancels modifications and exits edit mode.

    In Visual Studio Integrated Designer, you can disable this feature in the EditModeEntering Event and EditModeExit Event.

    See Also