Back to Devexpress

IdxRichEditSubDocument.Tables Property

vcl-dxrichedit-dot-nativeapi-dot-idxricheditsubdocument-37df73dc.md

latest3.1 KB
Original Source

IdxRichEditSubDocument.Tables Property

Provides access to the collection of tables in the document.

Declaration

delphi
property Tables: IdxRichEditTableCollection read;

Property Value

TypeDescription
IdxRichEditTableCollection

A table collection in a document.

|

Remarks

Use the Tables property to access and manage all tables in the current document.

Available Options

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.

Code Example: Create and Populate a Table

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
  }

See Also

IdxRichEditSubDocument.InsertTable Function

IdxRichEditSubDocument Interface

IdxRichEditSubDocument Members

dxRichEdit.NativeApi Unit