Page 1 of 1

add rows and columns in table without reformatting

Posted: Tue Nov 15, 2005 3:17 pm
by Guest
Can I add rows and columns in a table without reformat.
Now I use aTable.InsertCols and without aEditor.reformat I can't use the new column. The seem probleem by adding a row.
I want to reformat my editor at the end of my procedure.

Posted: Wed Nov 16, 2005 7:34 pm
by Sergey Tkachenko
It's not necessary to reformat the whole document, but the table must be reformatted. It can be done by BeginItemModify & EndItemModify methods.

Copied from Demos\Delphi\Editors\Editor 1\

Code: Select all

var item: TCustomRVItemInfo;
    table: TRVTableItemInfo;
    Data: Integer;
    rve: TCustomRichViewEdit;
    ItemNo: Integer;
begin
  if not RichViewEdit1.CanChange or
     not RichViewEdit1.GetCurrentItemEx(TRVTableItemInfo, rve, item) then
    exit;
  table := TRVTableItemInfo(item);
  ItemNo := rve.GetItemNo(table);
  rve.BeginItemModify(ItemNo, Data);
  case Operation of
    1:
      table.InsertRowsAbove(1);
    2:
      table.InsertRowsBelow(1);
    3:
      table.InsertColsLeft(1);
    4:
      table.InsertColsRight(1);
  end;
  rve.EndItemModify(ItemNo, Data);
  rve.Change;
end;