Udostępnij za pośrednictwem


Adding Text Boxes to a Report (Visual Studio Report Designer)

A text box is a report item that contains single instance data on the report. Examples of ways you might use a text box include adding a title to a report, adding specific fields in the page header or footer, or adding single-instance data like customer contact information on an order detail report.

Text boxes include a label, a value, and other properties. The value is always specified as an expression. The expression can contain static text, point to a field in the database, or calculate data.

The following table provides examples of expressions that you can use in a text box.

Expression Description

="This is static text"

Displays a static text label.

=Fields!UnitCost.Value

Displays the value of the UnitCost field.

=Fields!TotalUnits.Value * Fields!UnitCost.Value

Multiplies the value of the TotalUnits field and the UnitCost field and displays the result.

=Sum(Fields!TotalUnits.Value)

Calculates the sum of the TotalUnits field across all rows in the group.

Note

To add multi-instance data to a report, use a data region rather than a text box. A List data region provides functionality for displaying repeating rows of data from a single column. For more information, see Adding List Data Regions (Visual Studio Report Designer) and Adding Data Regions to a Report (Visual Studio Report Designer).

How to Add, Move, and Delete a Text Box

To add a text box

  1. Open the client report definition (.rdlc) file in graphical design mode.

  2. In the Toolbox, click Textbox.

  3. On the design surface of the report, drag a box to the size you want the text box to be. Alternatively, click the design surface to create a text box of fixed size.

After the text box is on the report, you can move it by pointing to the shaded border of the text box and dragging it to a new location. To delete a text box, right-click any empty space within the text box and press DELETE.

How to Bind a Field to a Text Box

To bind data to a text box, you can drag a field from the Data Sources window onto the text box, type an expression into the text box, or type an expression into the Value property in the Properties window.

Note

If the Data Sources window does not appear, in the Data menu, click Show Data Sources.

You can edit expressions using the expression editor. Using the expression editor, you can insert items into an expression from a list of available collections. You can access the expression editor by right-clicking on the text box and then choosing Expression, choosing Expression for the Value property in the Properties window, or by clicking the expression button for the Value property in the Textbox Properties dialog box.

How to Set the Locale on a Text Box

To set the locale on a text box

  1. Select the text box to which you want to apply the locale settings.

  2. In the Properties window, do the following:

    • For the Calendar property, type or select the calendar that you want to use for dates.

    • For the Direction property, type or select the horizontal direction in which the text is written.

    • For the Language property, type or select the language that you want to use for the text box.

    • For the NumeralLanguage property, type or select the format to use for numbers in the text box.

    • For NumeralVariant, type or select the variant of the format to use for numbers in the text box.

    • For UnicodeBiDi, select the level of bi-directional embedding to use in the text box.

Growing and Shrinking a Text Box

By default, text boxes are a static size. If you want to expand a text box vertically based on its contents, change the CanGrow property for the text box. If you want to allow the text box to shrink based on its contents, change the CanShrink property for the text box. You can access these properties through the Properties window or through the Textbox Properties dialog box.

See Also

Concepts

Creating Data Sources for a Report
Adding Data Regions to a Report (Visual Studio Report Designer)
Defining a Report Layout (Visual Studio Report Designer)
Creating Client Report Definition (.rdlc) Files