vcl-dxrichedit-dot-nativeapi-878637a9.md
A collection of tables in a document.
IdxRichEditTableCollection = interface(IdxRichEditReadOnlyTableCollection)
A document or subdocument exposes its tables through a table collection interface (IdxRichEditTableCollection).
The list below outlines key members of the IdxRichEditTableCollection interfaces. These members allow you to manage tables in a rich text document.
AddCreates a new table at the specified position within the parent document.CountReturns the number of tables in the collection.Delete | RemoveDelete a table stored in the collection.First | LastProvide access to first and last tables in the collection.IndexOfReturns the index of the specified table in the collection.Self
Provides indexed access to individual tables in the collection.
Use the Count property to obtain the number of tables accessible through the Self property.
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
}
The IdxRichEditSubDocument.Tables property references the IdxRichEditTableCollection interface.
IInterface IdxReadOnlyList<T> IdxRichEditReadOnlyTableCollection IdxRichEditTableCollection
See Also
IdxRichEditSubDocument.InsertTable Function