I thought that I would quickly share this code with you that removes all empty tables in a document.
An ArrayList is used to collect all tables in which cells are empty. This is required, because it is not possible to remove an object from a collection when iterating through this collection. Therefore, we are using two loops: The first to get the empty tables and the second loop to remove the tables from the collection.
private void removeEmptyTables() { ArrayList deleteTables = new ArrayList(); foreach (TXTextControl.Table curTable in textControl1.Tables) { deleteTables.Add(curTable); foreach (TXTextControl.TableCell curCell in curTable.Cells) { if (curCell.Text != "") { deleteTables.Remove(curTable); continue; } } } foreach (TXTextControl.Table delTable in deleteTables) { textControl1.InputPosition = new TXTextControl.InputPosition(delTable.Cells.GetItem(1, 1).Start); textControl1.Tables.Remove(); } }