RichTextBox Tables
int rows = 4;
int cols = 5;
int[,] matrix = new int[rows, cols];
Random rnd = new Random();
for (int i = 0; i < rows; i++)
for (int j = 0; j < cols; j++)
matrix[i, j] = rnd.Next(0, 11);
Table table = new Table();
for (int i = 0; i < cols; i++)
table.Columns.Add(new TableColumn());
TableRowGroup group = new TableRowGroup();
table.RowGroups.Add(group);
for (int i = 0; i < rows; i++)
{
TableRow row = new TableRow();
for (int j = 0; j < cols; j++)
{
TableCell cell = new TableCell(
new Paragraph(new Run(matrix[i, j].ToString())));
cell.BorderBrush = System.Windows.Media.Brushes.Black;
cell.BorderThickness = new System.Windows.Thickness(5);
row.Cells.Add(cell);
}
group.Rows.Add(row);
}
FlowDocument document = new FlowDocument(table);
TextRange range = new TextRange(document.ContentStart, document.ContentEnd);
MemoryStream stream = new MemoryStream();
range.Save(stream, DataFormats.Rtf);
string rtfTable = Encoding.UTF8.GetString(stream.ToArray());
richTextBox1.Rtf = rtfTable;
Are there any code examples left?
New code examples in category Other
-
Other 2023-03-27 22:50:10 how to select the whole line in vscode with keyboard shortcut
-
Other 2022-03-27 22:45:24 income of a web developer
-
Other 2022-03-27 22:35:01 \pyrcc_main.py: File does not exist 'resources.qrc'
-
Other 2022-03-27 22:30:45 rick roll embed code
-
Other 2022-03-27 22:20:08 Circuit_04_Potentiometer
-
Other 2022-03-27 22:20:05 iterative power
-
Other 2022-03-27 22:15:11 flutter run all
-
Other 2022-03-27 22:10:05 when is karlson release
-
Other 2022-03-27 22:10:02 wp .htaccess example
-
Other 2022-03-27 22:00:08 bash pause in file read line by line