Page 1 of 1

How to prevent a table cell to get focus?

Posted: Mon May 01, 2006 2:50 pm
by dudubaiao
Hi,

I'm filling some cells of a table with text and other cells with TEdits.
I just want to avoid that the user sets the focus on the text cells.

Search on RVItem unit I found this:

TRVItemBoolPropertyEx = (rvbpPrintToBMP, rvbpJump,
rvbpAllowsFocus,rvbpHotColdJump,
rvbpXORFocus, rvbpHotCold, rvbpActualPrintSize)

But I could not know if I can use this with table cells.

Posted: Mon May 01, 2006 6:16 pm
by Sergey Tkachenko
This property has different meaning (this "focus" is a dotted rectangle that TRichView (not TRichViewEdit) can draw around some items, such as hyperlinks).

You can use table.OnCellEditing event to move caret to another cell.
For example, this code does not allow to put caret in cells of the first column:

Code: Select all

procedure TForm3.CellEditing(Sender: TRVTableItemInfo; Row, Col: Integer;
  Automatic: Boolean; var AllowEdit: Boolean);
begin
  AllowEdit := Col>0;
end;
Table events are not saved in RVF files (and are lost on copy-pasting). To prevent this problem, this event should be assigned in OnItemAction event:

Code: Select all

procedure TForm3.RichViewEdit1ItemAction(Sender: TCustomRichView;
  ItemAction: TRVItemAction; Item: TCustomRVItemInfo; var Text: String;
  RVData: TCustomRVData);
begin
  if (ItemAction=rviaInserting) and (Item.StyleNo=rvsTable) then
    TRVTableItemInfo(Item).OnCellEditing := CellEditing;
end;