vcl-dxrichedit-dot-nativeapi-9f9150b6.md
Exposes a table in a document.
IdxRichEditTable = interface(IInterface)
You can create simple or nested tables in a rich text document.
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.
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.
BottomPadding | LeftPadding | RightPadding | TopPaddingSpecify individual paddings for cell content.PreferredWidth | PreferredWidthType | TableCellSpacing | TableLayoutSpecify general table layout 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.
BordersAllows you to configure individual table borders.StyleProvides access to table style settings.TableBackgroundColorSpecifies the table’s background color.
BeginUpdate | EndUpdateAllow you to avoid excessive redraw operations during batch table changes.ResetRestores initial table settings.
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 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.
IInterface IdxRichEditTable
See Also