Skip to main content

XRTableRowCollection.Insert(Int32, XRTableRow) Method

Adds the specified table row to the collection at the specified position.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v24.1.dll

NuGet Package: DevExpress.Reporting.Core

Declaration

public void Insert(
    int index,
    XRTableRow row
)

Parameters

Name Type Description
index Int32

A zero-based integer that specifies the position at which the table row is to be inserted.

row XRTableRow

An XRTableRow object that specifies the table row to insert into the collection.

Remarks

The Insert method allows you to insert a table row at a specific position. Elements that follow the insertion point are moved down to accommodate the new element.

If the index parameter is equal to or greater than the number of elements in the collection, the new element is appended to the end.

To add a new elements to the end of the collection, see the XRTableRowCollection.AddRange method.

Example

The following example demonstrates how to create an XRTable control at runtime. To do this, the XRTable.CreateTable, XRTable.InsertRowBelow and XRTable.InsertRowAbove methods are used.

After performing the code below, a table with five rows and three columns should be created.

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

public XRTable CreateTable1() {
    // Create a table containing three rows and three columns.
    XRTable tab = XRTable.CreateTable(new Rectangle(10, 10, 300, 120), 3, 3);

    // Set the border width for all table cells at a time.
    tab.BorderWidth = 2;

    // Make the borders visible for all table cells.
    tab.Borders = DevExpress.XtraPrinting.BorderSide.All;

    // Insert a new row into the table above the first row.
    tab.InsertRowAbove(tab.Rows[0]);

    // Insert a new row into the table below the last row.
    tab.InsertRowBelow(tab.Rows[3]);

    return tab;
}
See Also