Back to Devexpress

IdxRichEditTable Interface

vcl-dxrichedit-dot-nativeapi-9f9150b6.md

latest6.1 KB
Original Source

IdxRichEditTable Interface

Exposes a table in a document.

Declaration

delphi
IdxRichEditTable = interface(IInterface)

Remarks

You can create simple or nested tables in a rich text document.

Main API Members

The list below outlines key members of the IdxRichEditTable interface. You can use these members to configure table layout and appearance as well as access and edit individual cells.

Table Structure-Related API Members

Cell | GetItem | SelfProvide access to individual table cells by row and column indexes.FirstRow | LastRowProvide access to first and last rows in the table.ForEachRowAllows you to apply the same set of changes to all rows in the table.MergeCellsMerges specified cells in the table.RowsAllows you to manage the table structure.

Table and Content Layout Settings

BottomPadding | LeftPadding | RightPadding | TopPaddingSpecify individual paddings for cell content.PreferredWidth | PreferredWidthType | TableCellSpacing | TableLayoutSpecify general table layout settings.

Document-Related Settings

Indent | TableAlignmentAllow you to adjust the table’s position in the parent document.NestingLevelReturns the table’s nesting level.ParentCellProvides access to the table’s parent cell (if the table is nested).RangeReturns the document range that corresponds to the table.

General Appearance Settings

BordersAllows you to configure individual table borders.StyleProvides access to table style settings.TableBackgroundColorSpecifies the table’s background color.

General-Purpose API Members

BeginUpdate | EndUpdateAllow you to avoid excessive redraw operations during batch table changes.ResetRestores initial table settings.

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 IdxRichEditTable Interface References

The following public API members reference the IdxRichEditTable interface:

IdxRichEditTableCollection.AddCreates a new table at the specified position within the parent document.IdxRichEditTableCollection.FirstProvides access to the first table in the collection.IdxRichEditTableCollection.LastProvides access to the last table in the collection.IdxRichEditTableCollection.SelfProvides indexed access to stored tables.

Inheritance

IInterface IdxRichEditTable

See Also

IdxRichEditTableCollection Interface

IdxRichEditTable Members

dxRichEdit.NativeApi Unit