如何从GridView
菜单中删除“按框显示分组”和“删除此列”?当我去参加活动时没有ShowGridMenu事件,所以THIS对我不起作用......
答案 0 :(得分:5)
为此目的使用GridView.PopupMenuShowing事件。
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;
}
}