popupmenu in a cell in Datagrid

How Can i popup a Cell defined popup menu from from code, (not from user's right click)?
I define the popup menu to be used from Event OnCellBeforeShowPopupMenu
Thank you in advance

Just to describe it better:
one column in a DataGrid is read only with the event CaneditCell and this column has also in each cell a button.

procedure TForm3.TMSFNCDataGrid1CanEditCell(Sender: TObject; AColumn, ARow: Integer; var ACanEdit: Boolean);
begin
acanedit:=AColumn<>2;
end;

I want the popup menu as asssigned by the OnCellBeforeShowPopupMenu event to be presented-popuped by code when the cell button is pressed.

procedure TForm3.TMSFNCDataGrid1CellBeforeShowPopupMenu(Sender: TObject; ACell: TTMSFNCDataGridCellCoord; APopupMenu: TPopupMenu; var ACanShow: Boolean);
begin
ACanShow:=(acell.Row>0) and (acell.Column=2);
if ACanShow then APopupMenu:=popmymenu;
end;

Under a special condtion, I need also this popup menu to be presented-popuped by code when the cell of this column gets the focus. Which event is the best to request the popup to be shown?

The popupmenu is based on the right-click behavior when assigning it to the grid. If you want to show it in a different way, you can use the OnCellClick for example.

1 Like