• [原] 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;
            }
        }
    }
  • 相关阅读:
    Oracle通过透明网关连接SQL SERVER
    无法初始化链接服务器 "(null)" 的 OLE DB 访问接口 "Microsoft.Jet.OLEDB.4.0" 的数据源
    DBGrid应用
    C#学习之C#3.0语言功能
    windows 下 java 环境配置
    discuz UCenter对接遇到问题总汇
    mysql 备份之mysqldump 常用命令
    struts2与FreeMarker 简单配置实现
    hessian 简单实现
    jquery ui
  • 原文地址:https://www.cnblogs.com/Tonyyang/p/5305516.html
Copyright © 2020-2023  润新知