如何在流文档中并排创建两个表

时间:2014-09-25 20:15:00

标签: wpf flowdocument

我想在流程文档中并排创建两个表。 我不想使用blockuicontainer。

1 个答案:

答案 0 :(得分:1)

这是所有组合,您需要将两个表放在另一个表中,该表的大小为一行,有两列,如下所示:

Table table1 = CreateTable1();
Table table2 = CreateTable2();

var containingTable = new Table();
var containingRowGroup = new TableRowGroup();
var containingColumn1 = new TableColumn();
var containingColumn2 = new TableColumn();

containingTable.Columns.Add(containingColumn1);
containingTable.Columns.Add(containingColumn2);
containingTable.RowGroups.Add(containingRowGroup);

var containingCell1 = new TableCell();
var containingCell2 = new TableCell();

containingCell1.Blocks.Add(new Section(table));
containingCell2.Blocks.Add(new Section(table2));

var containingRow = new TableRow();
containingRow.Cells.Add(containingCell1);
containingRow.Cells.Add(containingCell2);

containingRowGroup.Rows.Add(containingRow);

document.Blocks.Add(new Section(containingTable));