Page 1 of 1

Operate On Table NOT In rvtoEditing

Posted: Mon Oct 27, 2008 8:55 pm
by DickBryant
I have a read-only table that is loaded with information contained elsewhere. I would like to be able to double click on CERTAIN cells and have a dialog pop up that offers to change the information in that cell.

In order for this to work, I need to obtain the cell location of the double click - I can work out the rest of the details. I cannot see how to obtain the click location in a table that does not have rvtoEditing enabled.

Thanks,

Dick

Posted: Tue Oct 28, 2008 2:07 pm
by Sergey Tkachenko

Code: Select all

procedure TForm1.RichViewEdit1RVMouseDown(Sender: TCustomRichView;
  Button: TMouseButton; Shift: TShiftState; ItemNo, X, Y: Integer);
var LItemNo, LOffs, r, c: Integer;
    LRVData: TCustomRVFormattedData;
    pt: TPoint;
    Table: TRVTableItemInfo;
begin
  if (Button<>mbLeft) or not (ssDouble in Shift) then
    exit;
  pt := Sender.ClientToDocument(Point(X, Y));
  if not Sender.GetItemAt(pt.X, pt.Y, LRVData, LItemNo, LOffs, False) then
    exit;
  LRVData := TCustomRVFormattedData(LRVData.GetSourceRVData);
  if not (LRVData is TRVTableCellData) then
    exit;
  Table := TRVTableCellData(LRVData).GetTable;
  Table.GetCellPosition(TRVTableCellData(LRVData), r, c);
  Application.MessageBox(PChar(Format('Cell %d %d', [r,c])), 'Editing', 0);
end;

Posted: Tue Oct 28, 2008 2:19 pm
by DickBryant
Thanks!

Just what I was looking for!