Delphi UniGUI PopupMenu

Delphi UniGUI PopupMenu

Feb 26, 2025

Let's connect the pop-up menu. It might look like this

image

The actual connection of the pop-up menu occurs in the code, in the OnCellContextClick event.

procedure TMainForm.UniDBGrid1CellContextClick(Column: TUniDBGridColumn; X, Y: Integer);

begin

if ClientDataSet.State in dsEditModes then

UniPopupMenu2.Popup(X, Y, UniDBGrid1)

else

UniPopupMenu1.Popup(X, Y, UniDBGrid1);

end;

The Popup menu itself is identical to the traditional Delphic analogue. We just need to place it on the form and configure it in the designer.

image

Well, and processing some events of our menus

TMainForm.Cancel1Click(Sender: TObject);

begin

if ClientDataSet.State in dsEditModes then

ClientDataSet.Cancel;

end;

procedure TMainForm.DeleteRowClick(Sender: TObject);

begin

ClientDataSet.Delete;

end;

procedure TMainForm.EditClick(Sender: TObject);

begin

ClientDataSet.Edit;

end;

procedure TMainForm.InsertRowClick(Sender: TObject);

begin

ClientDataSet.Insert;

end;

procedure TMainForm.PostClick(Sender: TObject);

begin

if ClientDataSet.State in dsEditModes then

ClientDataSet.Post;

end;

Enjoy this post?

Buy DelphiFan Forum a coffee

More from DelphiFan Forum