Reports for WinForms | ComponentOne
Working with C1PrintDocument / Tables / Styles in Tables
In This Topic
    Styles in Tables
    In This Topic

    Though table cells, columns, and rows are not render objects (they do not derive from the RenderObject class), they do have some properties similar to those of render objects. In particular, they all have the Style property.

    Manipulating styles affects the corresponding element and all its content. Setting the style of a row will affect all cells in that row. Setting the style of a column will affect all cells in that column. The style of the cell at the intersection of that row and column will be a combination of the styles specified for the row and the column. If the same style property is set on both the row and the column, the column will take precedence.

    Additionally, groups (groups of rows, groups of columns, and user cell groups) all have their own styles, which also affect the display of data in cells, and the display of table rows and columns.

    The following rules govern the application of styles in tables:

    Ambient style properties propagate down through the table elements (the whole table, row and column groups, cell groups, individual rows and columns, and individual cells) based on the "geometric" containment, similar to how ambient style properties propagate down render objects' containment outside of tables.

    Ambient properties affect the cells' content, without affecting those container elements. For instance, setting the font on the style of a whole table affects all text within that table unless its font was explicitly set at a lower level. Similarly, setting the font on the style of a row within that table affects the font of all cells within that row.

    When a specific ambient property is changed on two or more of the table elements involved, the following order of precedence is used to calculate the effective value of the property used to draw the cell:

    Non-ambient properties set on styles of table elements listed above (whole table, row, column and cell groups, rows, columns and cells) are applied to those elements themselves, without affecting the content of the cells, even though such elements (with the exception of the whole table) are not render objects. For instance, to draw a border around a row in a table, set the Style.Borders on the row to the desired value.

    To set a non-ambient style property on all cells in a table, use RenderTable.CellStyle. If specified, that style is effectively used as the parent for the style of render object within cells.

    The CellStyle property is also defined on rows, columns, and groups of table elements, and if specified all those styles will affect non-ambient properties of the object within the cell. For instance, to set the background image for all cells in a table, set the table's CellStyle.BackgroundImage. This will repeat that image in all cells in a table, while assigning the same image to the table's Style.BackgroundImage will make that image the background for the whole table (the difference is apparent if the image is stretched in both cases).