Skip to main content

XRTable.InsertColumnToRight(XRTableCell, Boolean) Method

Inserts a column into the table to the right of the column that contains the cell passed as the parameter.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v24.1.dll

NuGet Package: DevExpress.Reporting.Core

Declaration

public XRTableCell[] InsertColumnToRight(
    XRTableCell baseCell,
    bool autoExpandTable
)

Parameters

Name Type Description
baseCell XRTableCell

An object of the XRTableCell class. If the baseCell parameter is null (Nothing in Visual Basic), the new column is added to the right of the last table column.

autoExpandTable Boolean

true to expand the table width to accommodate a new column; false to fit the column into the current table width.

Returns

Type Description
XRTableCell[]

An array of XRTableCell objects representing the inserted column.

Remarks

Rows of an XRTable can have a varying number of cells. It is possible that a row may not have any cells for a particular column. Individual cells can differ from each other by their width and may not be aligned. This method inserts a column only into those table rows that contain cells aligned on their right side with the cell passed as the parameter.

When a column is inserted into a table and the autoExpandTable parameter is set to false, the cells that have their right side aligned with the cell passed as the parameter will have their width decreased to accommodate the new column. Their width will be decreased by an amount equal to half the width of their narrowest cell, and this width will be occupied by the new column’s cells.

Example

The following code demonstrates different ways of inserting cells and columns into an XRTable control. The original table contains one column. The second column is created by adding two individual cells using the XRTableRow.InsertCell method. The third and fourth columns are added by the XRTable.InsertColumnToRight and XRTable.InsertColumnToLeft methods, correspondingly.

using System.Drawing;
using DevExpress.XtraReports.UI;
// ...

public XRTable CreateTable() {
// Create an XRTable object containing two rows and one column.
    XRTable tab = XRTable.CreateTable(new Rectangle(200, 10, 200, 120), 2, 1);

    // Set the visible borders and their width for each table cell.
    tab.Borders = DevExpress.XtraPrinting.BorderSide.All;
    tab.BorderWidth = 2;

    // Create new cells.
    XRTableCell cell0 = new XRTableCell();
    XRTableCell cell1 = new XRTableCell();

    // Insert the new cells into the appropriate rows.
    tab.Rows.FirstRow.InsertCell(cell0, 0);
    tab.Rows.LastRow.InsertCell(cell1, 0);
    // The table has two columns now.

    // Insert a column to the right of the first row cell.
    tab.InsertColumnToRight(cell1);
    // The table has three columns now.

    // Insert a column to the left of the second row cell.
    tab.InsertColumnToLeft(cell1.NextCell);
    // The table has four columns now.

    return tab;
}
See Also