• [原] XAF ListView 凍結列


     

    using System;
    using System.ComponentModel;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.Text;
    
    using DevExpress.ExpressApp;
    using DevExpress.ExpressApp.Actions;
    using DevExpress.Persistent.Base;
    using DevExpress.ExpressApp.Win.Editors;
    using DevExpress.XtraGrid.Views.Grid;
    using DevExpress.XtraGrid.Columns;
    using DevExpress.Utils.Menu;
    using DevExpress.XtraGrid.Menu;
    using System.Drawing;
    using DevExpress.ExpressApp.Utils;
    
    namespace E1554.Module
    {
        public partial class FixclomunViewController : ViewController<ListView>
        {
            public FixclomunViewController()
            {
                InitializeComponent();
              
            }
    
            protected override void OnDeactivated()
            {
                base.OnDeactivated();            
            }
    
            protected override void OnViewControlsCreated()
            {
                base.OnViewControlsCreated();
                // Access and customize the target View control.
                GridListEditor listEditor = ((ListView)View).Editor as GridListEditor;
                if (listEditor != null)
                {
                    XafGridView gridView = listEditor.GridView as XafGridView;
                    gridView.PopupMenuShowing += new PopupMenuShowingEventHandler(gridView_PopupMenuShowing);
                }
    
            }
            private void gridView_PopupMenuShowing(object sender, PopupMenuShowingEventArgs e)
            {
                if (e.MenuType == DevExpress.XtraGrid.Views.Grid.GridMenuType.Column)
                {
                    DevExpress.XtraGrid.Menu.GridViewColumnMenu menu = e.Menu as GridViewColumnMenu;              
                    
                    if (menu.Column != null)
                    {
                      
                        //Adding new items
                        DXPopupMenu popMenu = new DXPopupMenu();
                        popMenu.Caption = "凍結列";
                        menu.Items.Add(popMenu);
    
                        popMenu.Items.Add(CreateCheckItem("取消", menu.Column, FixedStyle.None,
                         ImageLoader.Instance.GetImageInfo("NotFixed").Image));
                        popMenu.Items.Add(CreateCheckItem("左側", menu.Column, FixedStyle.Left,
                         ImageLoader.Instance.GetImageInfo("FixedLeft").Image));
                        popMenu.Items.Add(CreateCheckItem("右側", menu.Column, FixedStyle.Right,
                          ImageLoader.Instance.GetImageInfo("FixedRight").Image));
                    }
                    
                }
            }
    
            //Create a menu item 
            DXMenuCheckItem CreateCheckItem(string caption, GridColumn column, FixedStyle style, Image image)
            {
                DXMenuCheckItem item = new DXMenuCheckItem(caption, column.Fixed == style,
                  image, new EventHandler(OnFixedClick));
                item.Tag = new MenuInfo(column, style);
                return item;
            }
    
            //Menu item click handler 
            void OnFixedClick(object sender, EventArgs e)
            {
                DXMenuItem item = sender as DXMenuItem;
                MenuInfo info = item.Tag as MenuInfo;
                if (info == null) return;
                info.Column.Fixed = info.Style;
            }
    
            //The class that stores menu specific information 
            class MenuInfo
            {
                public MenuInfo(GridColumn column, FixedStyle style)
                {
                    this.Column = column;
                    this.Style = style;
                }
                public FixedStyle Style;
                public GridColumn Column;
            }
        }
    }
  • 相关阅读:
    OI无关--关于侧边栏
    Codeforces Round #528 div1
    BZOJ 3531: [Sdoi2014]旅行
    BZOJ 4538: [Hnoi2016]网络
    Codeforces Round #527 (Div. 3)
    Avito Cool Challenge 2018
    Educational Codeforces Round 56 (Rated for Div. 2)
    Codeforces Round #526 (Div. 1)
    2018-2019 Russia Open High School Programming Contest (Unrated, Online Mirror, ICPC Rules, Teams Preferred)
    Codeforces Round #525 (Div. 2)
  • 原文地址:https://www.cnblogs.com/Tonyyang/p/5305516.html
Copyright © 2020-2023  润新知