Einzelnen Beitrag anzeigen

question

Registriert seit: 17. Apr 2013
97 Beiträge
 
#1

runtime popupmenu on specific TDBGrid cell

  Alt 24. Sep 2013, 22:30
Hi
Since few days,i am trying to solve one problem, but still now not suscess I have a TDBGrid: DBGrid1, i want to create runtime cotext menu by right mouse click on the grid cell. For example, if i right click on the DBGrid cell then it will check the value of the selected cell and if the value is true only then it will show the popup menu
i cannot use any event handler(onmouse up or on mousedown or onclick), its possible to create the popupmenu 'onshow event' using the following code but then it shows the popupmenu everywhere i click on the DBGrid but i want to show the popup menu on specific cell,could anybody please tell me, how to do it?
Code:
procedure TForm2.FormShow(Sender: TObject);
var
NewPopup: TPopupmenu;
MenuItem: TMenuItem;
begin
// i have tried here to set the condition, for example:
//s := DBGrid1.DataSource.DataSet.FieldByName('tutorial_id').AsInteger;
if s=10 then // but it does not work
NewPopup := TPopupMenu.Create(nil);
MenuItem := TMenuItem.Create(NewPopup);
MenuItem.Caption := 'Send-Click';
NewPopup.Items.Add(MenuItem);
DBGrid1.PopupMenu := NewPopup;
end;

Geändert von question (25. Sep 2013 um 09:07 Uhr)
  Mit Zitat antworten Zitat