开发者

Remove gridview options

开发者 https://www.devze.com 2023-03-05 02:03 出处:网络
How to remove 开发者_如何学C\"Show Group By Box\" and \"Remove This Column\" from GridView menu? When I go to events there are no ShowGridMenuevent so THIS will not work for me...Use the GridView.Popu

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;
                }
        }
0

精彩评论

暂无评论...
验证码 换一张
取 消