Back to Devexpress

IdxRichEditTableCollection Interface

vcl-dxrichedit-dot-nativeapi-878637a9.md

latest4.3 KB
Original Source

IdxRichEditTableCollection Interface

A collection of tables in a document.

Declaration

delphi
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.

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.

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:

delphi
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;
cpp
_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
  }

Direct IdxRichEditTableCollection Interface Reference

The IdxRichEditSubDocument.Tables property references the IdxRichEditTableCollection interface.

Inheritance

IInterface IdxReadOnlyList<T> IdxRichEditReadOnlyTableCollection IdxRichEditTableCollection

See Also

IdxRichEditSubDocument.InsertTable Function

IdxRichEditTableCollection Members

dxRichEdit.NativeApi Unit