Skip to main content
A newer version of this page is available. .

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.

table-control-drag-from-toolbox

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.

table-control-add-to-multiple-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.

table-control-in-report-explorer

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.

table-control-cell-static-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.

table-control-cell-drop-other-control

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.

xrtable-convert-to-labels

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.

table-control-drop-fileds-from-field-list

Drag and drop the same fields with the right mouse button to create column headers with the corresponding field names.

table-control-drop-captions-from-field-list

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

table-cell-smart-tag-expression-binding

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

XRTable.InsertColumnToLeft

Inserts a new column to the left of the current cell shifting the leftmost column(s) to the left.

xrtable-insert-column-to-left

The added cells have the default width and copy the source cell’s appearance settings.

XRTable.InsertColumnToRight

Inserts a new column to the right of the current cell shifting the rightmost column(s) to the right.

xrtable-insert-column-to-right

The added cells have the default width and copy the source cell’s appearance settings.

XRTable.InsertRowAbove

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).

xrtable-insert-row-above

The added cells have the default width and copy the appearance settings of the source cell.

XRTable.InsertRowBelow

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).

xrtable-insert-row-below

The added cells have the default width and copy the appearance settings of the source cell.

XRTableRow.InsertCell

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.

xrtable-insert-cell

XRTable.DeleteRow

Deletes a row shifting the existing cells up.

xrtable-delete-row

XRTable.DeleteColumn

Deletes a column shifting the existing cells to the left.

xrtable-delete-column

XRTableRow.DeleteCell

Deletes a cell from the current table row.

xrtable-delete-cell

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.

table-control-multiple-selected-cells

Use the arrow that appears when a mouse cursor hovers over the table edges to select an entire row or column.

table-control-select-rows-and-columns

Click the table-control-select-table-button 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.

    table-control-regular-resizing

  • 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).

    table-control-resizing-with-ctrl

  • Resizing a column while holding the SHIFT key shifts the other columns in the corresponding direction without changing their size.

    table-control-resizing-with-shift

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.

table-control-cell-column-span

Use the XRTableCell.RowSpan property to specify the number of rows the table cell spans.

table-control-cell-row-span

See Also