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.
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.
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. |
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.
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.
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. |
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,
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.
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.
You can use other text formatting properties in combination with the ShrinkToFit property.
Caution:
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.
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.
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.
To set Line or Character spacing,
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 Word, HTML, PDF and Image formats.
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.