Report Authors / Report Controls / Report Controls in Page/RDLX Report / TextBox
TextBox

The Textbox report control is the most commonly used report control that displays textual data in any report.  

In Page and RDLX reports, the TextBox by default appears in each cell of a Table or Tablix data region. Also, a TextBox is what is created when you drag a field from the data set onto the report. In the Value 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.

In the Properties panel, there are a number of properties that you can use to control the appearance and behavior of the TextBox. For example, you can set the Action property to have the viewer jump to a bookmark within the report, another report, or a URL when a user clicks the TextBox at run time. The Data Element properties allow you to control how and whether the TextBox displays in XML exports.

By default, in RDLX reports, the TextBox can grow vertically to accommodate the data it displays, and it cannot shrink smaller than it appears at design time. To change this behavior, set the CanShrink and CanGrow properties in the Properties grid.

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 panel or code through the Value property.

Textbox 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 panel. Formats apply to all of the text in the control. Text formatting changes in the Properties panel immediately appear in the control, and changes made in the toolbar are immediately reflected in the Properties panel.

Important Properties

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

Property Description

RDLX report

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.
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.
ShrinkToFit Determines whether ActiveReports decreases the font size when text values exceed available space.
TextJustify Specifies text justification with TextAlign set to Justify.
Value A field, constant, or expression, which value is displayed in the textbox.
VerticalAlignment Gets or sets the position of the textbox's text vertically within the bounds of the control.
WrapMode Indicates whether a multi-line textbox control automatically wraps words or characters to the beginning of the next line when necessary.

Page report

CharacterSpacing Gets or sets a character spacing in points.
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.
ShrinkToFit Determines whether ActiveReports decreases the font size when text values exceed available space.
TextJustify Specifies text justification with TextAlign set to Justify.
Value A field, constant, or expression, which value is displayed in the textbox.
VerticalAlignment Gets or sets the position of the textbox's text vertically within the bounds of the control.
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 panel, 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 (/), backslash (\), exclamation (!), and hyphen (-) are not supported.

Tooltip: A textual label for the report item used to include TITLE or ALT attributes in HTML reports.

Value: A field, constant, or expression, which value is displayed in the textbox.

Note: When the group or dataset breaks to a new page, the first instance of the repeated value is printed.

Data Fields

When you drag a field from a dataset and drop it onto the report surface, a TextBox report control with an expression is automatically created. The type of expression that is created depends upon the context where you drop the field. The following table describes the various contexts and expressions created if you drag a field named SalesAmount onto the report.

Expressions created for fields in different contexts

Note: The expression created is different for a field with a string or unknown data type. In these cases, the First aggregate is used in place of the Sum aggregate in the expressions below. At run time, the first value found within the scope is displayed instead of a summary.
Context Expression Run-Time Behavior
Directly on the report surface =Sum(Fields!SalesAmount.Value) Displays a summary of the sales amount for the entire dataset.
List data region =Fields!SalesAmount.Value Displays a value for each row of data, in a list running down the page.
BandedList data region, header, or footer band =Sum(Fields!SalesAmount.Value) Displays a summary of the sales amount for the dataset associated with the BandedList.
BandedList data region, detail band =Fields!SalesAmount.Value Displays a value for each row of data, in a list running down the page.
BandedList data region, group header, or footer band =Sum(Fields!SalesAmount.Value) Displays a summary of the sales amount for the grouping.
Table data region, header, or footer row =Sum(Fields!SalesAmount.Value) Displays a summary of the sales amount for the dataset associated with the Table.
Table data region, detail row =Fields!SalesAmount.Value Displays a value for each row of data, in a list running down the page.
Table data region, group header or footer row =Sum(Fields!SalesAmount.Value) Displays a summary of the sales amount for the grouping.
Tablix data region, corner cell none Displays a blank cell. You can add a label or even use this area to embed other report control.
Tablix data region, column group cell =Fields!SalesAmount.Value Displays the value at the top of a new column for each row of data running to the right.
Tablix data region, row group cell =Fields!SalesAmount.Value Displays the value to the left of a new row for each row of data running down the page.
Tablix data region, body cell =Sum(Fields!SalesAmount.Value) Displays a summary of the sales amount for the intersection of the column and row.

TextBox Features

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 TextAlign property must be set to Justify for TextJustify property to affect the text layout.

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

Auto

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.

Distribute

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

DistributeAllLines

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 panel.
  2. In the Properties panel, set the TextAlign property
  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, export a report in PDF, and TIFF formats, or render a report in Word, HTML, PDF and Image formats using rendering extensions.  

Shrink Text to Fit in a Control

When working with the Textbox control in a Page report and RDLX 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.

The following image illustrates the result when the ShrinkToFit property is set to True on 'Title' field.

TextBox with ShrinkToFit set to True

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

Caution:

  • 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 when the WritingMode property is set for a control.
  • Common value with Page number (in data region or report header/footer) appears clipped in exported files (HTML, MHT, Word, and Excel) even when ShrinkToFit property for the TextBox is set to True.

On exporting a report, various file formats handle ShrinkToFit differently. ShrinkToFit gets exported in all formats except Text. While rendering a Page report or RDLX report using rendering extensions, ShrinkToFit is not supported in XML. However, all other rendering extensions allow ShrinkToFit to display as it is.

Multi-line in TextBox

You can display multi-line text in TextBox and some other controls such as CheckBox for Page/RDLX reports.

In a Page/RDLX report, with your control in edit mode, insert line breaks at the desired location using the Enter key or Ctrl + Enter key to create multi-line text. You can also insert line breaks in the Expression Editor through the Value property of the control.

Note: In edit mode, scrollbars appear automatically to fit multi-line 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 multi-line 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 and Character Spacing in TextBox

To set Line or Character spacing,

  1. On the design surface, click the TextBox control to display it in the Properties panel.
  2. In the Properties panel, 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 report. It is also supported while rendering a report through rendering extensions in WordHTMLPDF and Image 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