How to merge cells/rows in flowdocument table?
-
I have been trying to implement merge cells/rows feature in WPF richtextbox containing flowdocument with table. found no built-in method which supports table.merge(tablecells). One way i think is to get the table cells in selection, set rowspan, colspan accordingly for the left most cell and remove other cells in the selection. but fidning it difficult even to get the cells in the selection
foreach (var rowGroup in table.RowGroups)
{
foreach (var row in rowGroup.Rows)
{
foreach (var cell in row.Cells)
{
if (richTextBox.Selection.Contains(cell.ElementStart))
{
int rowIndex = rowGroup.Rows.IndexOf(row);
int colIndex = row.Cells.IndexOf(cell);
selectedTableCells.Add(new KeyValuePair<int, int>(rowIndex, colIndex), cell);
}
}
}
}code above doesnot return the correct number of cells in the selection. any help? Is there a better way to do this?
- Regards -
J O N
A good thing is a bad thing if it keeps you from the best thing. - Dr. Adrian Rogers