Table
- 5 minutes to read
This document describes the XRTable control and illustrates its main features.
This topic consists of the following sections:
Table Overview
The XRTable control displays information in a tabular format and allows you to create table reports.
Tip
Unlike data-aware grids, such as WinForms GridControl, the XRTable does not have its own data source. You can bind table cells to the fields from the report’s data source as described below.
You can add a table control by dragging the XRTable item from the toolbox DX.17.2: Report Controls tab onto the report’s area.
You can also create two tables simultaneously, for instance, one that shows column titles in the Page Header and one that shows regular information in the Detail band. Select the XRTable item in the Toolbox and draw a rectangle across these bands.
The XRTable control contains one or more rows (XRTableRow objects) stored in the XRTable.Rows collection. Each row contains one or more cells (XRTableCell objects) that you can access using the XRTableRow.Cells property. See the Report Explorer for a table structure example.
Use the XRControl.Text property to specify the cell’s static text. You can double-click the cell to invoke its in-place editor and type the desired text.
You can also make a table cell act as a container for other report controls by dropping the required control from the toolbox on this cell.
The XRTable.ConvertToControls method allows you to transform a table into a set of XRLabel controls by right-clicking a table or any of its cells and selecting Convert To Labels in the context menu. Table cells containing other controls are converted to XRPanel controls.
You can assign different visual styles for even and odd table rows to improve readability.
A table cell is like an XRLabel control - it provides the same options for text formatting, alignment, appearance, interactivity, etc. See the Label topic to learn how to specify these options.
Data Binding
You can create a table control with cells bound to data fields obtained from a report’s data source using the Field List. Select data fields by clicking them while holding the CTRL or SHIFT key and drop them onto the Detail band.
Drag and drop the same fields with the right mouse button to create column headers with the corresponding field names.
You can bind individual table cells to data in the same ways as label controls. For instance, click the cell’s smart tag, expand the Expression drop-down list and select the required data field
Clicking the Expression option’s ellipsis button invokes the Expression Editor. This allows you to construct a complex binding expression involving two or more data fields.
See the Binding Report Controls to Data topic to learn more about the available data binding modes and creating data-aware controls.
The XRControl.ProcessDuplicatesMode and XRControl.ProcessDuplicatesTarget options enable you to merge cells with identical values.
Managing Table Structure
You can manage table cells, row and columns as described in the table below.
Action | Behavior |
---|---|
Inserts a new column to the left of the current cell shifting the leftmost column(s) to the left. The added cells have the default width and copy the source cell’s appearance settings. | |
Inserts a new column to the right of the current cell shifting the rightmost column(s) to the right. The added cells have the default width and copy the source cell’s appearance settings. | |
Inserts a row above the current cell shifting the existing rows up if there is enough space above the table (otherwise, shifts the existing rows down). The added cells have the default width and copy the appearance settings of the source cell. | |
Inserts a row below the current cell shifting the existing rows down if there is enough space under the table (otherwise, increases the band height by the default row height). The added cells have the default width and copy the appearance settings of the source cell. | |
Divides the current cell width in half and inserts a new cell to the left. The added cell copies the source cell’s appearance settings. | |
Deletes a row shifting the existing cells up. | |
Deletes a column shifting the existing cells to the left. | |
Deletes a cell from the current table row. |
Selecting and Resizing Table Elements
You can select a table cell by clicking it, and then access cell settings using the Property Grid or smart tag. To select multiple cells, press and hold the SHIFT or CTRL key while clicking the required cells.
Use the arrow that appears when a mouse cursor hovers over the table edges to select an entire row or column.
Click the button at the table’s left bottom corner to select the whole table. You can also use this button to move the table to a new location.
You can resize a table or its cell by dragging the rectangle drawn on the corresponding edge or corner. The table supports three column resizing modes:
Resizing a column changes the neighboring cells’ width (at the left or right depending on the direction) without affecting the table width and other cells.
Resizing a column while holding the CTRL key changes the width of the cells in the corresponding direction while maintaining their width in proportion to the overall table width (keeping the table dimensions intact).
Resizing a column while holding the SHIFT key shifts the other columns in the corresponding direction without changing their size.
You can make a table cell occupy several rows or columns. Remove a specific cell by pressing DELETE or selecting Delete | Cell in the context menu, and resize the remaining cells to get the required result.
Use the XRTableCell.RowSpan property to specify the number of rows the table cell spans.