Udostępnij za pośrednictwem


Adding Rectangles, Lines, and Borders to a Report (Visual Studio Report Designer)

You can use rectangles, lines, images, and border styles to create visual effects within a report. Rectangles can be used to contain other report items or decorate the report. Images can either be static or based on data in a database. Border properties can be set for any item that occupies space in the report layout. For more information about images, see Adding Images to a Report (Visual Studio Report Designer).

Adding a Report Border

You can add a border to a report by adding borders to the headers, footers, and report body. In the header, add a left, top, and right border. In the body, add a left and right border. In the footer, add a left, bottom, and right border. If you do not use headers in your report, you can place borders around just the report body.

If you add a report border that appears on the page header and footer, do not suppress the header and footer on the first and last pages of the report. If you do, the border may appear cut off at the top or bottom of the first and last pages of the report.

To define the border, set border width, color, and style properties of the Body, Page Header, and Page Footer objects in the Properties window.

Note

Although you can use a rectangle to create a border around the entire report page, it is not recommended because at run time some report items grow to accommodate repeating rows of data. If you put data regions such as tables, lists, and matrices within a rectangle, the actual dimensions of the rectangle might vary from one report rendering to the next if the amount of data changes between renderings.

Adding a Rectangle

Although a rectangle can be used exclusively for visual effect, it is more commonly used as a container for other items. A rectangle allows you to group items together. When you move the rectangle, the items that are contained within the rectangle move along with it.

When using rectangles to contain report items, consider how the items will be affected as a whole during report rendering. Report items that contain repeated rows of data (for example, tables) will expand to accommodate the data that is returned by a query, and this affects the positioning of other items in the rectangle. A table will push items down if they are positioned below the data region. To anchor an item in place, you can place the report item inside of a rectangle that has an upper edge above the lower edge of the table. To add a rectangle to a report, do the following:

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

  2. In the Toolbox, click Rectangle.

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

Note

Dragging a rectangle around existing items does not automatically place the items within the rectangle. To place existing items in a rectangle, create the rectangle, and then drag the items to the rectangle.

Adding Lines

You can add lines to a report layout. By default, a line is a non-repeating design element. If you want to add a line within repeating rows of data (for example, in some cell of a detail row), you must write an expression that draws the line and puts the expression in the cell where you want the line to appear. If you want to always add a line after the repeating data, you don’t' need an expression. Simply set the Repeat report item with data region on every page option in the Line Properties dialog box. To add a line to a report, do the following:

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

  2. In the Toolbox, click Line.

  3. On the design surface, drag a box to create a line that runs from the point where you pressed the mouse button to the point where you released the mouse button.

See Also

Reference

Line Properties Dialog Box - General Tab (Visual Studio Report Designer)
Rectangle Properties Dialog Box - General Tab (Visual Studio Report Designer)
Style Properties Dialog Box - Border and Line Tab (Visual Studio Report Designer)

Concepts

Defining a Report Layout (Visual Studio Report Designer)
Defining Page Size and Page Breaks in a Report (Visual Studio Report Designer)
Adding Data Regions to a Report (Visual Studio Report Designer)