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

XRTableRow.InsertCell(XRTableCell, Int32) Method

Inserts the cell into the table row.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v18.2.dll

Declaration

public void InsertCell(
    XRTableCell cell,
    int index
)

Parameters

Name Type Description
cell XRTableCell

An XRTableCell object to be inserted into the table row.

index Int32

An integer value indicating the position in which to insert the cell, in the collection of row cells.

Remarks

The inserted cell will occupy the position to the left of the cell identified by the index parameter. If the index parameter exceeds the maximum index of the row cells then the inserted cell will occupy the position to the left of the rightmost row cell.

The width of the cell to the right of the inserted one will be reduced in a half. Another half will be occupied by the inserted cell.

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