How to remove 开发者_如何学C"Show Group By Box" and "Remove This Column" from GridView
menu? When I go to events there are no ShowGridMenu event so THIS will not work for me...
Use the GridView.PopupMenuShowing event instead for this purpose.
private void gridView1_PopupMenuShowing(object sender, DevExpress.XtraGrid.Views.Grid.PopupMenuShowingEventArgs e) {
if(e.MenuType == GridMenuType.Column)
RemoveItem(e.Menu, GridLocalizer.Active.GetLocalizedString(GridStringId.MenuColumnRemoveColumn));
else
if(e.MenuType == GridMenuType.Group)
RemoveItem(e.Menu, GridLocalizer.Active.GetLocalizedString(GridStringId.MenuGroupPanelShow));
}
private void RemoveItem(GridViewMenu menu, string caption) {
for(int i = 0; i < menu.Items.Count; i ++)
if(menu.Items[i].Caption == caption) {
menu.Items.RemoveAt(i);
break;
}
}
精彩评论