ImageEn, unit iexRichEdit |
|
TIERichEdit.GetTableProperties
Declaration
function TIERichEdit.GetTableProperties(out ColCount: Integer;
out RowCount: Integer;
out ColWidth: Integer;
out RowHeight: Integer;
out BorderSize: Integer;
out BorderColor: TColor;
out TableAlignment: TAlignment;
out CellVertAlign: TVerticalAlignment;
out CellMargin: Integer;
out BackgroundColor: TColor;
out Indent: Integer
): Boolean;
Description
Returns properties of the currently selected table.
Result is false if there is not a table selected.
Note:
◼RowCount should be specified as -1 to update the properties entire table
◼If ColCount is different from the current count, cells will be added or deleted
◼GetTableProperties() requires an entire row to be selected. If there is no selection, this will occur automatically
◼You can update the table using using
SetTablePropertiesRich Edit Identifier: EM_GETTABLEPARMS
var
colCount: Integer;
rowCount: Integer;
colWidth: Integer;
rowHeight: Integer;
tableAlign: TAlignment;
cellVertAlign: TVerticalAlignment;
borderSize: Integer;
borderColor: TColor;
cellMargin: Integer;
bgColor: TColor;
indent: Integer;
initIndex: Integer;
begin
// Works best if the cursor is positioned inside the first cell
if IERichEdit1.SelLength = 0 then
begin
initIndex := IERichEdit1.SelStart;
// GetTableProperties() requires whole row to be selected
IERichEdit1.SelectAll( True );
end
else
initIndex := IERichEdit1.SelStart + 2; // Whole row has been selected, position cursor inside the first cell
// Get existing properties
if IERichEdit1.GetTableProperties( colCount, rowCount,
colWidth, rowHeight,
borderSize, borderColor,
tableAlign, cellVertAlign,
cellMargin,
bgColor,
indent ) = False then
raise Exception.create( 'You have not selected a table (click inside the first cell of the table)' );
// Update background color to red
bgColor := clRed;
// Vertically align the text
cellVertAlign := taVerticalCenter;
// Make border color green
borderColor := clGreen;
// SettTableProperties() requires cursor to be positioned inside first cell, doesn't support row selection :-/
if IERichEdit1.SelLength > 0 then
IERichEdit1.SetSelection( initIndex, initIndex );
// Update the properties
if IERichEdit1.SetTableProperties( colCount,
-1, // Update whole table
colWidth, rowHeight,
borderSize, borderColor,
tableAlign, cellVertAlign,
cellMargin,
bgColor,
indent ) = False then
raise Exception.create( 'Cannot set table properties' );
end;
See Also
◼SetTableProperties◼InsertTable