|
Table Operations |
Top Previous Next |
|
Operations on Selection Inserting rows and columns: Deleting rows can columns:
Other Operations Inserting rows and columns: Deleting rows can columns:
Assigning Table Properties (As Editing Operations) Methods for assigning table properties: Methods for assigning row properties: Methods for assigning cell properties: Operations in Viewer and Editor If the operations above are performed before inserting the table, no addition actions are required. If these operations are performed on table inserted in TRichView, you need to call Format method after to update the document view. If these operations are performed on table inserted in TRichViewEdit, a special sequence of steps is required:
The example is below. You can group several actions so that they will be undone/redone as whole, using SetUndoGroupMode In order to perform operation(s) on table, you need to get table object.You can do it using method function TRichView.GetItem(ItemNo: Integer): TCustomRVItemInfo; TCustomRVItemInfo is an ancestor class for all items of RichView, including table (TRVTableItemInfo). This method can be used for item of any type, so you need to check if it is a table (using "is" operator, or checking RichView.GetItemStyle(ItemNo)=rvsTable) But usually, when you need to perform operations on the item at the position of caret in editor, you do not know if the current item is in "root" editor, or inside cell, or inside cell of table inside other cell, and so on. In any case, you can get item in position of caret with method function TRichViewEdit.GetCurrentItem: TCustomRVItemInfo; But even if the caret is inside table, the current item will be not a table, but some other item in cell-inplace editor! The problem can be solved with the method function TRichViewEdit.GetCurrentItemEx( RequiredClass: TCustomRVItemInfoClass; var ItemRichViewEdit: TCustomRichViewEdit; var Item: TCustomRVItemInfo): Boolean; In this method,
This editor can be "root" RichViewEdit or cell inplace editor. Example // MyRichViewEdit:TRichViewEdit is an editor // placed on the form at design time. // Note: the most of operations are performed in // rve (editor returned by GetCurrentItemEx), // not in MyRichViewEdit. var item: TCustomRVItemInfo; table: TRVTableItemInfo; Data: Integer; rve: TCustomRichViewEdit; ItemNo: Integer; begin if not MyRichViewEdit.CanChange or not RichViewEdit1.GetCurrentItemEx(TRVTableItemInfo, rve, item) then exit; table := TRVTableItemInfo(item); ItemNo := rve.GetItemNo(table); rve.BeginItemModify(ItemNo, Data); // performing some operation, for example // table.InsertRowsBelow(1); // or table.CellPadding := 10 rve.EndItemModify(ItemNo, Data); rve.Change; end; |