设置DBGrid1.PopupMenu:=PopupMenu1;
假设PopumMenu1为你已经设计好的TPopupMenu;

解决方案 »

  1.   

    TO li_zhifu(东北人) 
    我老是没有你快,真的啊;
    就是li_zhifu(东北人) 说的那样;
      

  2.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, Grids, DBGrids, Menus;type
      TForm1 = class(TForm)
        DBGrid1: TDBGrid;
        PopupMenu1: TPopupMenu;
        N1: TMenuItem;
        d1: TMenuItem;
        sdf1: TMenuItem;
        procedure DBGrid1MouseDown(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.DBGrid1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    var
      p: TPoint;
    begin
     if Button=mbRight then
     begin
      p:=DBGrid1.ClientToScreen(Point(X,Y));
      PopupMenu1.Popup(p.x,p.y);
     end;
    end;end.
      

  3.   

    在窗口上加入一个DBGrid, 一个PopupMenu,给PopupMenu随便加上几项,加入DBGrid1MouseDown,把DBGrid1MouseDown的代码Paste一下,就可以测试了。
    至于“不同的数据,产生不同的菜单”,用SelectedField,SelectedIndex,SelectedRows中即可(不用全用的)。因为点右键的同时,这三个变量会发生相应的变化的。
      

  4.   

    to Detective(探长) 我在网吧上网,看了你的方案,我想是可行现在我暂且给你10分,试过后,再给你加上10分,谢谢!
      

  5.   

    to Detective(探长) 我今天发现,是不是分没有给上去?我第一次给分,如果有误,对不起
      

  6.   

    var 
    pt: TPoint; 
    begin 
     if Button=mbRight then 
       begin 
       pt:=DBGrid1.ClientToScreen(Point(x,y)); 
       PopupMenu1.Popup(pt.x,pt.y); 
    end;