右键单击菜单自定义gridControl / gridView1(C#/ DevExpress)以编程方式

时间:2016-10-09 08:12:56

标签: c# devexpress gridcontrol

如何在gridcontrol上自定义右键菜单?我尝试将导出选项放在菜单上。我尝试在网格设计中搜索仍然无法找到它。尝试谷歌这几周。需要掌握指导。 TQ

enter image description here

2 个答案:

答案 0 :(得分:0)

您可以从代码或设计器添加一个控件名称 contextmenu ,然后添加一些事件。你可以自己谷歌或Adding a right click menu to an item

答案 1 :(得分:0)

您可以处理GridView的PopupMenuShowing event并自定义内置的网格菜单:

private void gridView1_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e)
{
    if (e.MenuType != DevExpress.XtraGrid.Views.Grid.GridMenuType.Column)
        return;

    DXMenuItem restoreItem = new DXMenuItem() { Caption = "Restore Layout" };
    restoreItem.Click += restoreItem_Click;

    e.Menu.Items.Add(restoreItem);
}

private void restoreItem_Click(object sender, EventArgs e)
{
    MessageBox.Show("Restoring layout...");
}

另请参阅:How to: Implement Custom Menu in XtraGrid Control