Border around a single table element

  • It seems this should be a simple task but I can't find how to set a border around the outside of a table with no borders inside the table, around a row without placing borders on the cells, and around a single cell while other cells are borderless.

    Any help appreciated!

    Tom

  • I forgot to mention that I am building and loading the tables in code.

    Version 6.14 is the latest available in my download area. I don't know if that affects the following.

    I'm creating my tables using CreateTable. I tried using SetInnerCellBorders and SetOuterCellBorders as shown but no borders were created. I couldn't find any documentation so I don't know if the TWPParagraphBordApply type should also allow these methods to border a row and a single cell as well.

    Is there a working demo using these methods? Any more information that will help me to place an outer border on a table and on a row within the table.

    Thanks.

    • Offizieller Beitrag

    Hi,

    the download area should now show 6.16. It always shows the date of the last upload.

    To understand the borders you need to know:
    - tables dont have borders
    - rows dont have borders
    - only cells have borders, left, top right and bottom.

    They are activated through the bitfield WPAT_BorderFlags, i.e.
    cell.ASetAdd(WPAT_BorderFlags, WPBRD_DRAW_Right)

    When you create the table you need to set the left border in the first cell, the righjt in the last in one row. And only in the cells in first row and last row the top and bottom border. All those are "outer" cells.

    The methods SetInnerCellBorders and SetOuterCellBorders are (in V6.16) just a shortcut to the method

    Code
    procedure SetBorderProperties(Inner, Outer: TWPTextStyle;         ApplyMode :   TWPParagraphBordApply;         Mode : TWPUpdateBorderProperties =         [wpSetBorderFlags,   wpSetBorderType,   wpSetBorderWidth,  wpSetBorderColor,  wpSetParColor,  wpSetParShading]);

    It will apply the selected attributes (Mode!) stored in "Outer" to the outer cell borders, and the attributes stored for Left and Top borders in "Inner" to the inner cells.

    If it is applied to one cell only it just uses the "Outer" definition.

    Since SetInnerCellBorders is a shortcut, it also serves as a good example to how to use the SetBorderProperties method:

    Here you see how it prepares the "Inner" Style, "Outer" is just empty.

    By default it works like the "Border Inner" action, it applies only the inner lines to a selection in a table. It was designbed to leave the outer lines alone.

    If you create your table in code You could of course create it without any lines and, at the end, when you are in the last cell, call

    SetOuterCellBorders(true, -1, wpapTable).

    Regards,

    Julian

  • Julian,

    Your explanation furthered my understanding of borders and how they're applied but I still cannot build a working example setting the inner and outer borders.

    This is one of many trials. Can you tell me what I am missing in my attempt to place an outer border on a 2x2 table?

    Thanks again.