vcl-dxrichedit-dot-nativeapi-dot-idxricheditsubdocument-37df73dc.md
Provides access to the collection of tables in the document.
property Tables: IdxRichEditTableCollection read;
| Type | Description |
|---|---|
| IdxRichEditTableCollection |
A table collection in a document.
|
Use the Tables property to access and manage all tables in the current document.
To create a new table anywhere within the document, call the Tables.Add function. If you need to delete a table, call the Tables.Delete or Tables.Remove procedure.
For detailed information on all available options, refer to the IdxRichEditTableCollection interface description.
The following code example creates a table with three rows and three columns at the current caret position and populates all cells in the table:
var
ADocument: IdxRichEditDocument;
ATable: IdxRichEditTable;
I, J: Integer;
begin
ADocument := dxRichEditControl1.Document;
ADocument.BeginUpdate; // Initiates the following batch change
try
ATable := ADocument.Tables.Add(ADocument.CaretPosition, 3, 3);
for I := 0 to ATable.Rows.Count - 1 do
for J := 0 to ATable.Rows.Self[I].Cells.Count - 1 do
ADocument.InsertText(ATable.Cell(I, J).Range.Start, 'Lorem ipsum dolor sit amet');
finally
ADocument.EndUpdate; // Calls EndUpdate regardless of the batch operation's success
end;
end;
_di_IdxRichEditDocument ADocument;
_di_IdxRichEditTable ATable;
// ...
ADocument = dxRichEditControl1->Document;
ADocument->BeginUpdate(); // Initiates the following batch change
try
{
ATable = ADocument->Tables->Add(ADocument->CaretPosition, 3, 3);
for(int i = 0; i < ATable->Rows->Count; i++)
for(int j = 0; j < ATable->Rows->Self[i]->Cells->Count; j++)
ADocument->InsertText(ATable->Cell(i, j)->Range->Start, "Lorem ipsum dolor sit amet");
}
__finally
{
ADocument->EndUpdate(); // Calls EndUpdate regardless of the batch operation's success
}
See Also
IdxRichEditSubDocument.InsertTable Function
IdxRichEditSubDocument Interface