// Create the Table... Table table1 = new Table(); // ...and add it to the FlowDocument Blocks collection. flowDoc1.Blocks.Add(table1);
// Set some global formatting properties for the table. table1.CellSpacing = 10; table1.Background = Brushes.White;
int numberOfColumns = 2; int rows = 2; int c;
for (int x = 0; x < numberOfColumns; x++) { table1.Columns.Add(new TableColumn());
for (int r = 0; r < rows; r++) { TableRow tr = new TableRow(); for (c = 0; c < numberOfColumns; c++) { tr.Cells.Add(new TableCell(new Paragraph(new Run())));
if (c % 2 == 0) tr.Cells[c].Background = Brushes.PapayaWhip; else tr.Cells[c].Background = Brushes.RoyalBlue; } TableRowGroup trg = new TableRowGroup(); trg.Rows.Add(tr); table1.RowGroups.Add(trg);
// Set contents RichTextControl.Document = flowDoc1;
} } }