TextBox report control is a data-bound input control which is used for entering and editing text-based information. It is the default data region that appears in each cell of a Table or Tablix report control and is automatically created when you drag a field from a dataset (data field) on the report.
When you drag a field from a dataset on the report design area, 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.
|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.|
You can select Expression… within many properties to open the Expression Editor. You can also access the Expression Editor from the context menu of the TextBox control.
The Text Justify property of a TextBox control provides you with justification options when you align the text within a control. You can choose from the following options.
You can also display text within a control on multiple lines. With the TextBox control in edit mode, insert line breaks at the desired location using the 'Enter' key or 'Shift' + 'Enter' key to create multiline text. You can also insert line breaks in the Expression Editor through the Value property of the control.
In order to make your report output clearly visible during export or printing, you can increase the space between characters and between lines using Character Spacing and Line Spacing properties, respectively. To visualize line spacing, you must first have multiple lines in the TextBox control.
You can use the Shrink To Fit 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 Shrink To Fit property.
The Min Condense Rate property allows users to shrink the width of the text so that it fits within the width of the control. With Min Condense Rate property,
the size of the text is compressed horizontally and all characters and character-spacing in the text shrink with the same ratio; while with Shrink To Fit property, both the height and width of a text are compressed.
when a text is multi-line, the width of the text shrinks based on the longest line. If the text cannot fit the width of the control even after the width of the text is compressed with the minimum ratio, line breaks are inserted in the middle of the text depending on the setting of the Wrap Mode property.
The default value of the Min Condense Rate property is 100% and the available range is from 10 to 100 (only natural number). When the Min Condense Rate property is specified, the following properties are ignored:
Let us create a report that uses TextBox controls to display the price and in-stock information, and total number of items in stock. We will be using Banded List control to contain text boxes and display data for each row. The final report will be as shown:
Drag-drop the Banded List control on the report’s designer.
From the dataset, drag the following data fields to the Details band of the Banded List control: [ProductID], [StorePrice], and [InStock]. All these fields are bound text boxes.
To provide headings (labels) to the data displayed in the text boxes in the Details band, drag-drop three TextBox controls onto the Header band of the Banded List control and set the Value property of the text boxes to Product ID, Store Price, and In Stock, respectively.
To display the total number of products in stock, drag-drop two TextBox controls onto the Footer band of the Banded List control and set the properties as follows.
=Sum(Fields!InStock.Value). This is a calculated text box; the expression calculates the total number of products in stock.
To provide the report's title, drag-drop another TextBox control onto the top center in the design area. Enter the text of the title into the Value property or directly inside the text box, e.g. Products Info.
To add the information on date of report generation, drag-drop TextBox control on the upper right corner of the report and set the Value property to expression
="Report Generation Date:" & Format(Now(), "dd/MM/yyyy").
Set the font style and alignment properties for the text boxes accordingly.