Skip to main content

IdxRichEditTableCollection Interface

A collection of tables in a document.

Declaration

IdxRichEditTableCollection = interface(IdxRichEditReadOnlyTableCollection)

Remarks

A document or subdocument exposes its tables through a table collection interface (IdxRichEditTableCollection).

Main API Members

The list below outlines key members of the IdxRichEditTableCollection interfaces. These members allow you to manage tables in a rich text document.

Add
Creates a new table at the specified position within the parent document.
Count
Returns the number of tables in the collection.
Delete | Remove
Delete a table stored in the collection.
First | Last
Provide access to first and last tables in the collection.
IndexOf
Returns 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.

Code Example: Insert a Table at the Caret Position

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;

VCL Rich Edit Control: A Table Example

Direct IdxRichEditTableCollection Interface Reference

The IdxRichEditSubDocument.Tables property references the IdxRichEditTableCollection interface.

See Also