Reports for WinForms | ComponentOne
Working with C1PrintDocument / Tables / Accessing Cells, Columns and Rows
In This Topic
    Accessing Cells, Columns and Rows
    In This Topic

    As can be seen from the sample code in the Tables topic, all cells in a table are represented by the Cells collection, which has the type TableCellCollection. Elements in this collection representing individual cells have the type TableCell. To access any cell in a table, the Cells collection can be indexed by the cell's row and column like this:

    To write code in Visual Basic

    Visual Basic
    Copy Code
    Dim rt As New C1.C1Preview.RenderTable()
    …
    ' get cell at row 10, column 4:
    Dim tc as TableCell = rt.Cells(10, 4)
    

    To write code in C#

    C#
    Copy Code
    RenderTable rt = new RenderTable();
    …
    // get cell at row 10, column 4:
    TableCell tc = rt.Cells[10, 4];
    

    Table columns are accessed via the Cols collection, which has the type TableColCollection, and contains elements of the type TableCol. As with cells, just "touching" a column will create it. For instance, if you set a property of a column's Style, that column will be created if it did not exist already.

    Table rows are accessed via the Rows collection, which has the type TableRowCollection, and contains elements of the type TableRow. As with cells and columns, just "touching" a row will create it. For instance, if you set the Height of a row it (and all rows before it) will be automatically created.

    Please note, though, that all table rows that do not contain cells with some actual content will have a zero height, so will not be visible when the table is rendered.