.NET 學習

.NET 學習生活感想... 万事成蹉跎..... 贵在坚持 及时整理自己做过和学过的东西

博客园 首页 新随笔 联系 订阅 管理
using System;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Win.Editors;
using DevExpress.Utils.Menu;
using DevExpress.XtraGrid.Menu;
using DevExpress.XtraGrid.Views.Grid;

namespace CommonModule.Common.Controlers
{   
        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;                
                _listEditor.GridView.OptionsView.ColumnAutoWidth = false;//啟用滾動條
            }

            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;
                if (_listEditor.GridView.OptionsView.ShowFooter)
                    menuCaption = "Hide Footer";
                else
                    menuCaption = "Show 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()
            {
              
                base.OnDeactivated();
                if (_listEditor == null || _listEditor.GridView == null) return;
                _listEditor.GridView.PopupMenuShowing -= GridView_PopupMenuShowing;
            }
        }
    
}

 

posted on 2014-11-29 12:26  Tonyyang  阅读(510)  评论(0编辑  收藏  举报
欢迎转载,转载请注明出处:http://www.cnblogs.com/Tonyyang/