Table in table, space after inner table

5 posts, 1 answers
  1. Stéphane
    Stéphane avatar
    8 posts
    Member since:
    Dec 2012

    Posted 19 Feb 2013 Link to this post

    WPF - V2012.3.1224.40 - VS2010

    Hello,

    I have programmatically added one table in another:

    Table l_Table = new Table();
    l_Table.LayoutMode = TableLayoutMode.AutoFit;
    ownerSection.Blocks.Add(l_Table);
     
    foreach (IFeatureViewModel l_Node in treeViewModel.Nodes)
    {
        TableRow l_Row = new TableRow(); l_Table.Rows.Add(l_Row);
     
        Table l_InnerTable = new Table();
        l_InnerTable.LayoutMode = TableLayoutMode.AutoFit;
     
        TableCell l_InnerCell = new TableCell(); l_Row.Cells.Add(l_InnerCell);
        l_InnerCell.Borders = new TableCellBorders(0.5f, BorderStyle.Single, System.Windows.Media.Colors.Red);
        l_InnerCell.Blocks.Add(l_InnerTable);
     
        TableRow l_InnerRow = new TableRow(); l_InnerTable.Rows.Add(l_InnerRow);
     
        ....

    The outer table cells have red borders and inner table cells have gray borders (see attached image).

    After the inner table there is a vertical space.
    How to remove this space ?

    Thanks
    Stephane

  2. Petya
    Admin
    Petya avatar
    975 posts

    Posted 20 Feb 2013 Link to this post

    Hello Stéphane,

    I am not quite sure what you are trying to achieve, but generally the approach you are using is not recommended and may cause different issues.

    What I mean is that a Table element, by design, cannot be the first or last block in a document and there cannot be adjacent tables in a document.  Moreover, the last block in a table cell has to be a paragraph (not a table). Thus, when inserting the inner table, the by design a mechanism prevents it from being the last block. You should probably make sure to insert empty paragraphs around such tables to prevent future issues:
    l_InnerCell.Blocks.Add(new Paragraph);
    l_InnerCell.Blocks.Add(l_InnerTable);
    l_InnerCell.Blocks.Add(new Paragraph);

    Moreover, I am not sure how you expect the table to look - do you expect for both borders to overlap or to have a little space between them? Generally, inserting an inner table should look like in the attached image and you can verify that be nesting tables in a RadRichTextBox using the UI.

    I hope the provided information helps! Let us know if you have other comments or questions.
     
    Greetings,
    Petya
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Stéphane
    Stéphane avatar
    8 posts
    Member since:
    Dec 2012

    Posted 22 Feb 2013 Link to this post

    Hello Petya, thanks for precise answer.

    My goal:
    I have an TreeListView control in my application (see attached image), I must "re-create" the control in a RadDocument for reporting.

    So, the first column wil contain the tree, and the other columns will contain item's data.

    Each cell of the first column (the inner table) is made of 3 elements:
    1) A varaible width placeholder to recreate hierarchy.
    2) An image.
    3) The item's name.

    The problem with paragraph before and after the inner table is the lost vertical space and aesthetics.

    Thanks
    Stephane
  5. Answer
    Boby
    Admin
    Boby avatar
    595 posts

    Posted 27 Feb 2013 Link to this post

    Hello Stéphane,
    Unfortunately this is limitation of the current document model. One option is to change paragraphs' font size to the minimum one (2) which will produce result visually closer to what you want to achieve.

    Kind regards,
    Boby
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  6. Stéphane
    Stéphane avatar
    8 posts
    Member since:
    Dec 2012

    Posted 27 Feb 2013 Link to this post

    Hello Boby.

    The font size trick is "good enough" and solved my problem.

    Thanks
    Regards
    Stéphane
Back to Top
UI for WPF is Visual Studio 2017 Ready