using System; using DevExpress.ExpressApp; using DevExpress.ExpressApp.Win.Editors; using DevExpress.Utils.Menu; using DevExpress.XtraGrid.Menu; using DevExpress.XtraGrid.Views.Grid; namespace E968.Module { public class ListViewFooterMenuViewController : ViewController { public ListViewFooterMenuViewController() { TargetViewType = ViewType.ListView; } GridListEditor _listEditor; protected override void OnViewControlsCreated() { base.OnViewControlsCreated(); _listEditor = ((ListView)View).Editor as GridListEditor; if (_listEditor == null) return; _listEditor.GridView.PopupMenuShowing += GridView_PopupMenuShowing; } void GridView_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e) { if (e.MenuType != GridMenuType.Column) return; var menu = e.Menu as GridViewColumnMenu; if (menu == null) return; string menuCaption = "Show Footer"; if (_listEditor.GridView.OptionsView.ShowFooter) menuCaption = "Hide Footer"; var item = new DXMenuCheckItem(menuCaption, _listEditor.GridView.OptionsView.ShowFooter, null, OnDrempelItemClick); menu.Items.Add(item); } private void OnDrempelItemClick(object sender, EventArgs e) { _listEditor.GridView.OptionsView.ShowFooter = !_listEditor.GridView.OptionsView.ShowFooter; } protected override void OnDeactivated() { _listEditor.GridView.PopupMenuShowing -= GridView_PopupMenuShowing; base.OnDeactivated(); } } }