[原] XAF 如何啟用ListView橫向滾動條

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

 

你可能感兴趣的:(ListView)