This is a migrated thread and some comments may be shown as answers.

Table in table, space after inner table

4 Answers 261 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Stéphane
Top achievements
Rank 1
Iron
Stéphane asked on 19 Feb 2013, 12:34 PM
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

4 Answers, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 20 Feb 2013, 12:53 PM
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.

0
Stéphane
Top achievements
Rank 1
Iron
answered on 22 Feb 2013, 07:06 AM
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
0
Accepted
Boby
Telerik team
answered on 27 Feb 2013, 07:55 AM
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.

0
Stéphane
Top achievements
Rank 1
Iron
answered on 27 Feb 2013, 10:42 AM
Hello Boby.

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

Thanks
Regards
Stéphane
Tags
RichTextBox
Asked by
Stéphane
Top achievements
Rank 1
Iron
Answers by
Petya
Telerik team
Stéphane
Top achievements
Rank 1
Iron
Boby
Telerik team
Share this question
or