其他分享
首页 > 其他分享> > CodeGo.net>将表添加到FlowDocument背后的代码

CodeGo.net>将表添加到FlowDocument背后的代码

作者:互联网

我已经试过了…..

_doc = new FlowDocument();

Table t = new Table();
for (int i = 0; i < 7; i++)
{
    t.Columns.Add(new TableColumn());
}

TableRow row = new TableRow();
row.Background = Brushes.Silver;
row.FontSize = 40;
row.FontWeight = FontWeights.Bold;

row.Cells.Add(new TableCell(new Paragraph(new Run("I span 7 columns"))));
row.Cells[0].ColumnSpan = 6;

_doc2.Blocks.Add(t);

当我去查看该文档时,该表永远不会显示…..尽管我在添加此表之前添加到该文档的边框图像和文档标题输出正常.

解决方法:

您将列添加到表中,但是将行添加到的代码在哪里?它只是没有连接.

添加类似:

...
var rg = new TableRowGroup();
rg.Rows.Add(row);
t.RowGroups.Add(rg);
_doc2.Blocks.Add(t);

标签:flowdocument,wpf,c
来源: https://codeday.me/bug/20191024/1917788.html