Operate On Table NOT In rvtoEditing

General TRichView support forum. Please post your questions here
Post Reply
DickBryant
Posts: 148
Joined: Wed Dec 07, 2005 2:02 pm
Contact:

Operate On Table NOT In rvtoEditing

Post 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
Sergey Tkachenko
Site Admin
Posts: 17566
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post 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;
DickBryant
Posts: 148
Joined: Wed Dec 07, 2005 2:02 pm
Contact:

Post by DickBryant »

Thanks!

Just what I was looking for!
Post Reply