How to: Delete a Table
The following example illustrates how to delete a table cell, row or an entire table.
- To delete a single cell, use the TableCell.Delete method. The required cell will be deleted and the next one will be moved to the left.
- The TableRow.Delete method deletes a specified row from the table.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/word-processing-document-api-examples-t418535
Document document = server.Document;
Table tbl = document.Tables.Create(document.Range.Start, 3, 3, AutoFitBehaviorType.AutoFitToWindow);
tbl.BeginUpdate();
tbl.Rows[2].Delete();
tbl.Cell(1, 1).Delete();
tbl.EndUpdate();
- To delete the whole table, delete it from the collection of tables contained in the current document. To do that, use the TableCollection.Remove method.