右键显示菜单项需要处理的事件:
- private void gridView3_ShowGridMenu(object sender, DevExpress.XtraGrid.Views.Grid.GridMenuEventArgs e)
- {
- if (e.MenuType == DevExpress.XtraGrid.Views.Grid.GridMenuType.Row)
- {
- GenMenu(e.Menu, gridView3.Name);
- }
- }
生成菜单项:
- void GenMenu(GridViewMenu gvMenu)
- {
- gvMenu.Items.Add(new DXMenuItem("Copy", new EventHandler(DoCopy),Resources.CopyHS));
- gvMenu.Items.Add(new DXMenuItem("Paste",new EventHandler(DoPaste),Resources.PasteHS));
- gvMenu.Items.Add(new DXMenuItem("Delete",new EventHandler(DoDel),Resources.DeleteHS));
- }
Resources.CopyHS:资源中的Copy图标,
Resources.PasteHS:资源中的Paste图标,
Resources.DeleteHS:资源中的Delete图标,
菜单项的处理事件:
- private void DoCopy(object sender, EventArgs args)
- {
- //Copy something
- }
- private void DoPaste(object sender, EventArgs args)
- {
- //Paste something
- }
- private void DoDelete(object sender, EventArgs args)
- {
- //Delete something
- }
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。