rvico TRichView Reference | Item Types | Table

TRVTableItemInfo.OnCellEditing

Top  Previous  Next

Occurs before starting editing of this cell and allows to prevent it.

type

  TRVCellEditingEvent = procedure (Sender: TRVTableItemInfo;

    Row, Col : Integer; Automatic: Boolean;

    var AllowEdit: Boolean) of object;

(introduced in version 1.7)

Input parameters

This event occurs when editor attempts to change content of Sender.Cells[Row, Col].

If Automatic=True, this is not actually a cell editing, but a multicell operation (clearing, applying style, etc.)

Output parameters

Set AllowEdit to False to disallow this operation.

 

Tables are not components, so their events cannot be assigned at design time in the Object Inspector. They must be assigned in code. Events are not saved in RVF files, so you need to reassign them when tables are loaded. The best place to assign this event is TRichView.OnItemAction event.

Example

// This procedure is assigned to OnCellEditing of all tables

procedure TMyForm.DoCellEditing(Sender: TRVTableItemInfo; Row, Col: Integer;

  Automatic: Boolean; var AllowEdit: Boolean);

begin

  // Preventing editing all cells in the top rows of all tables

  if Row=0 then

    AllowEdit := False;

end;

 

// MyRichViewEdit.OnItemAction. Assigns DoCellEditing to

// OnCellEditing events of all tables inserted in MyRichViewEdit.

// (this assignment occurs when table is inserted using 

// AddItem or InsertItem methods, or is loaded from RVF or RTF file)

procedure TMyForm.MyRichViewEditItemAction(Sender: TCustomRichView;

  ItemAction: TRVItemAction; Item: TCustomRVItemInfovar Text: String;

  RVData: TCustomRVData);

begin

  if (Item.StyleNo = rvsTable) and (ItemAction = rviaInserting) then

    TRVTableItemInfo(Item).OnCellEditing := DoCellEditing;

end;

 

See also:

TParaInfo.Options (rvpaoReadOnly, rvpaoStyleProtect, rvpaoDoNotWantReturns – protection options for paragraphs);

TFontInfo.Protection (protection options for text);

TRVExtraItemProperty (rvepDeleteProtect, rvepResizable – protection option for nontext items).


TRichView © trichview.com