怎样实现在DBGRID中单击右键弹出弹出式菜单? 设置DBGrid1.PopupMenu:=PopupMenu1;假设PopumMenu1为你已经设计好的TPopupMenu; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 TO li_zhifu(东北人) 我老是没有你快,真的啊;就是li_zhifu(东北人) 说的那样; 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. 在窗口上加入一个DBGrid, 一个PopupMenu,给PopupMenu随便加上几项,加入DBGrid1MouseDown,把DBGrid1MouseDown的代码Paste一下,就可以测试了。至于“不同的数据,产生不同的菜单”,用SelectedField,SelectedIndex,SelectedRows中即可(不用全用的)。因为点右键的同时,这三个变量会发生相应的变化的。 to Detective(探长) 我在网吧上网,看了你的方案,我想是可行现在我暂且给你10分,试过后,再给你加上10分,谢谢! to Detective(探长) 我今天发现,是不是分没有给上去?我第一次给分,如果有误,对不起 var pt: TPoint; begin if Button=mbRight then begin pt:=DBGrid1.ClientToScreen(Point(x,y)); PopupMenu1.Popup(pt.x,pt.y); end; 为什么有些情况,软件可以处于顶层,有些不可以,请教了 TComboBox自动打开下拉框 编写组件,如何添加外部事件? 清高手和版主帮忙! 一个简单的问题,控件的长,宽,高都什么为单位(缇,像素,....) 关于Delphi6和5的简单问题 proecedure身明的小问题 如何在delphi程序中使用西班牙语? 关于关闭FORM,很简单! 急!急!急!长字串的折行打印输出 请赐教 请问如何用 SHFileOperation 给文件改名 ? 菜鸟笨笨地问。
我老是没有你快,真的啊;
就是li_zhifu(东北人) 说的那样;
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.
至于“不同的数据,产生不同的菜单”,用SelectedField,SelectedIndex,SelectedRows中即可(不用全用的)。因为点右键的同时,这三个变量会发生相应的变化的。
pt: TPoint;
begin
if Button=mbRight then
begin
pt:=DBGrid1.ClientToScreen(Point(x,y));
PopupMenu1.Popup(pt.x,pt.y);
end;