We help IT Professionals succeed at work.

Prevent popup menu on grid

Bosanac
Bosanac asked
on
How can I prevent when a user right clicks on a grid to activate my popup menu ?
I would like that option only on form itself and not on components..
Comment
Watch Question

Lukasz Zielinskisoftware developer
CERTIFIED EXPERT
Top Expert 2008

Commented:
>>How can I prevent when a user right clicks on a grid to activate my popup menu ?

don't assign PopupMenu property

>>I would like that option only on form itself and not on components

eventually you can turn off .AutoPopup and trigger menu by .Popup() function

ziolko.
Create a new popup menu that has no menu items, and assign that new popup menu to the grid.  Problem solved.
Lukasz Zielinskisoftware developer
CERTIFIED EXPERT
Top Expert 2008

Commented:
>>Create a new popup menu that has no menu items, and assign that new popup menu to the grid

isn't it simpler not to assign popup menu to grid at all?

ziolko.
Mike LittlewoodEngineer
CERTIFIED EXPERT

Commented:
Either remove the popup menu at design time, or based on some security of the currently logged on user do it in code

procedure TForm1.FormCreate(Sender: TObject);
begin
   if not canUsePopup then
      DBGrid1.PopupMenu := nil
end;
zioko : The author has a popup menu assigned to his form.  If he has no popup assigned to his other components, the form's popup will be effective when he right clicks.  He wants there to be no popup menu when he right clicks his grid component.

Ideally, he should not have a popup assigned to his form but only to the components where he wants the popup to work, but I'm not here to define his best practices, I've just helped him with a solution.
Lukasz Zielinskisoftware developer
CERTIFIED EXPERT
Top Expert 2008

Commented:
>>The author has a popup menu assigned to his form.

ooops my mistake
Forced accept.

Computer101
EE Admin

Explore More ContentExplore courses, solutions, and other research materials related to this topic.