Nevron Open Vision Documentation
Rich Text Editor / Document Model / Styles / Table Styles
In This Topic
    Table Styles
    In This Topic

    Table styles are rich text styles that can be applied to table elements.

     Table Part Styles

    A table style typically consists of one or more table part styles, each of which lets you specify the styling to apply on a given table part like background, border, margins, padding, and so on. Each table part also can have a ParagraphRule and an InlineRule, which determine the style of paragraphs and inlines in that table part. The image below illustrates the table parts you can define styles for:

     Part Styles Priority

    As the image above shows, there's some overlapping of table parts, for example, the top left cell style collides with the whole table, first row, first column, odd row, and odd column styles. Such collisions are resolved automatically by Nevron when applying styles, because table parts styles have different priority. The following list shows the priority of the table parts styles in ascending order, i.e. from least important to most important:

    Note that you can specify on a per table basis which table part styles should be applied, for example for one table you may want only the first row and first column styles to be applied, while for another table you may want only first and last row styles to be applied. To achieve this you should use the StyleOptions property of the table, which accepts one or more enum values of type ENTableStyleOptions (a flagged enum). The following code example demonstrates how to change it to first and last row styles:

    Table Style Options
    Copy Code
    table.StyleOptions = ENTableStyleOptions.FirstRow | ENTableStyleOptions.LastRow;
    
    The StyleOptions property of a table is by default set to: first row, even row, odd row and first column.
     Code Example

    The code below demonstrates how to create a custom table style and apply it to a table element:

    Table Style Example
    Copy Code
    NTableStyle customStyle = new NTableStyle("CustomTableStyle");
    customStyle.WholeTable = new NTablePartStyle();
    customStyle.WholeTable.Border = new NBorderRule(ENPredefinedBorderStyle.Solid, NColor.DarkRed, new NMargins(1));
    customStyle.WholeTable.Border.InsideHSides = new NBorderSideRule(ENPredefinedBorderStyle.Solid, NColor.DarkRed, 1);
    customStyle.WholeTable.Border.InsideVSides = new NBorderSideRule(ENPredefinedBorderStyle.Solid, NColor.DarkRed, 1);
    
    customStyle.FirstRow = new NTablePartStyle();
    customStyle.FirstRow.BackgroundFill = new NColorFill(NColor.DarkRed);
    customStyle.FirstRow.InlineRule = new NInlineRule(NColor.White);
    customStyle.FirstRow.InlineRule.FontStyle = ENFontStyle.Bold;
    
    customStyle.Apply(table);
    

    As a result the styled table will look like this:

     

    See Also