Back to Devexpress

XRTableCell.RowSpan Property

xtrareports-devexpress-dot-xtrareports-dot-ui-dot-xrtablecell.md

latest5.0 KB
Original Source

XRTableCell.RowSpan Property

Specifies the number of rows in the XRTable control that the cell spans.

Namespace : DevExpress.XtraReports.UI

Assembly : DevExpress.XtraReports.v25.2.dll

NuGet Package : DevExpress.Reporting.Core

Declaration

csharp
[DefaultValue(1)]
[SRCategory(ReportStringId.CatBehavior)]
public int RowSpan { get; set; }
vb
<SRCategory(ReportStringId.CatBehavior)>
<DefaultValue(1)>
Public Property RowSpan As Integer

Property Value

TypeDefaultDescription
Int321

An integer value that specifies the number of rows.

|

Remarks

The RowSpan property allows you to specify the number of merged cells. For this property to work properly, a table should have a cell with the same width in the row below the current one.

You can also make a cell occupy several columns by specifying appropriate cell widths. The width of the target cell should be equal to the sum of the cells in the neighboring row.

Note

  • Users cannot edit merged cells in Preview.
  • New controls cannot be dropped onto the merged cells.
  • The XRTableCell.CanGrow and XRTableCell.CanShrink properties have no effect on the merged cells.
  • The odd and even styles are not applied to merged cells when a report is exported to HTML or to file formats that support a continuous (table-like) layout (such as TXT or CSV).
  • Cells that span multiple rows may be split between pages. A split cell duplicates its content on the next page.
  • The RowSpan value can be interpreted incorrectly when a table changes layout in the BeforePrint event handler.

Example

The following code demonstrates how to create a table with the layout shown in the image below.

csharp
using DevExpress.XtraReports.UI;
// ...

private XRTable CreateTable() {
    XRTable table = new XRTable();
    table.Borders = DevExpress.XtraPrinting.BorderSide.All;
    table.BeginInit();
    table.SizeF = new SizeF(400f, 50f);
    XRTableRow row1 = new XRTableRow() { HeightF = 25f };
    XRTableRow row2 = new XRTableRow() { HeightF = 25f };
    row1.Cells.AddRange(new XRTableCell[] {
        new XRTableCell() {Text = "Cell1", WidthF = 100f, RowSpan = 2},
        new XRTableCell() {Text = "Cell2", WidthF = 100f},
        new XRTableCell() {Text = "Cell3", WidthF = 200f}
    });
    row2.Cells.AddRange(new XRTableCell[] {
        new XRTableCell() {WidthF = 100f},
        new XRTableCell() {Text = "Cell4", WidthF = 100f},
        new XRTableCell() {Text = "Cell5", WidthF = 100f},
        new XRTableCell() {Text = "Cell6", WidthF = 100f}
    });
    table.Rows.AddRange(new XRTableRow[] { row1, row2 });
    table.EndInit();
    return table;
}
vb
Imports DevExpress.XtraReports.UI
' ...

Private Function CreateTable() As XRTable
    Dim table As New XRTable()
    table.Borders = DevExpress.XtraPrinting.BorderSide.All
    table.BeginInit()
    table.SizeF = New SizeF(400F, 50F)
    Dim row1 As New XRTableRow() With {.HeightF = 25F}
    Dim row2 As New XRTableRow() With {.HeightF = 25F}
    row1.Cells.AddRange(New XRTableCell() {
        New XRTableCell() With {.Text = "Cell1", .WidthF = 100F, .RowSpan = 2},
        New XRTableCell() With {.Text = "Cell2", .WidthF = 100F},
        New XRTableCell() With {.Text = "Cell3", .WidthF = 200F}
    })
    row2.Cells.AddRange(New XRTableCell() {
        New XRTableCell() With {.WidthF = 100F},
        New XRTableCell() With {.Text = "Cell4", .WidthF = 100F},
        New XRTableCell() With {.Text = "Cell5", .WidthF = 100F},
        New XRTableCell() With {.Text = "Cell6", .WidthF = 100F}
    })
    table.Rows.AddRange(New XRTableRow() { row1, row2 })
    table.EndInit()
    Return table
End Function

See Also

XRTableCell Class

XRTableCell Members

DevExpress.XtraReports.UI Namespace