[Lazarus] Popup menu on a TStringGrid row

Juha Manninen juha.manninen at phnet.fi
Tue Jun 8 23:50:48 CEST 2010


Thanks Graeme and Henry!

Based on your hints and code I finally created these:

-------------

procedure TReplaceNamesForm.PopupMenu1Popup(Sender: TObject);
var
  ControlCoord, NewCell: TPoint;
begin
  ControlCoord := Grid.ScreenToControl(PopupMenu1.PopupPoint);
  NewCell:=Grid.MouseToCell(ControlCoord);
  Grid.Col:=NewCell.X;
  Grid.Row:=NewCell.Y;
end;

procedure TReplaceNamesForm.InsertRow1Click(Sender: TObject);
begin
  Grid.InsertColRow(False, Grid.Row);
end;

procedure TReplaceNamesForm.DeleteRow1Click(Sender: TObject);
begin
  Grid.DeleteColRow(False, Grid.Row);
end;

----------------

Popup handler set focus to the cell under mouse and then 2 handlers Insert and 
Delete rows.
Now there is visual feedback when the user clicks a cell. It gets colored and 
there is no guessing about which row will be deleted.
It is pretty much perfect now. :-)

Juha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20100609/6d874dba/attachment-0004.html>


More information about the Lazarus mailing list