Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the UpgradeHelpers.Windows.Forms.ExtendedGridView class with the corresponding container
        /// </summary>
        /// <param name="container">The container where the Grid is going to be hosted</param>
        public DataGridViewFlex(IContainer container)
        {
            DoubleBuffered = true;
            InitializeComponent();
            _controlKeyDown           = new KeyEventHandler(control_KeyDown);
            _controlKeyUp             = new KeyEventHandler(control_KeyUp);
            _controlKeyPress          = new KeyPressEventHandler(control_KeyPress);
            this.CellMouseEnter      -= new DataGridViewCellEventHandler(ExtendedDataGridView_CellMouseEnter);
            this.CellMouseEnter      += new DataGridViewCellEventHandler(ExtendedDataGridView_CellMouseEnter);
            this.RowHeaderMouseClick += ExtendedDataGridView_RowHeaderMouseClick;
            isInitializing            = false;
            Reset();
            #region Designer related code

            IServiceContainer serviceContainer = container as IServiceContainer;
            if (serviceContainer != null)
            {
                ExtendedDataGridViewPropertyFilter newMyFilter = new ExtendedDataGridViewPropertyFilter();
                DesignerActionService designerActionService    = serviceContainer.GetService(typeof(DesignerActionService)) as DesignerActionService;
                //DesignerActionUIService designerActionUIService = serviceContainer.GetService(typeof(DesignerActionUIService)) as DesignerActionUIService;
                newMyFilter.oldService            = (ITypeDescriptorFilterService)serviceContainer.GetService(typeof(ITypeDescriptorFilterService));
                newMyFilter.designerActionService = designerActionService;
                //newMyFilter.designerActionUIService = designerActionUIService;
                if (newMyFilter.oldService != null)
                {
                    serviceContainer.RemoveService(typeof(ITypeDescriptorFilterService));
                }

                serviceContainer.AddService(typeof(ITypeDescriptorFilterService), newMyFilter);
            }

            // Acquire a reference to IComponentChangeService
            //This service is used during design to make sure that we do not allow the user
            //to edit Columns properties when the grid is in MSFlexGrid compatibility
            IComponentChangeService changeService = container as IComponentChangeService;
            if (changeService != null)
            {
                changeEventHandler = new ComponentChangingEventHandler(changeService_ComponentChanging);
                changeService.ComponentChanging -= changeEventHandler;
                changeService.ComponentChanging += changeEventHandler;
            }
            #endregion
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the UpgradeHelpers.Windows.Forms.ExtendedGridView class with the corresponding container
        /// </summary>
        /// <param name="container">The container where the Grid is going to be hosted</param>
        public DataGridViewFlex(IContainer container)
        {
            InitializeComponent();
            _controlKeyDown = new KeyEventHandler(control_KeyDown);
            _controlKeyUp = new KeyEventHandler(control_KeyUp);
            _controlKeyPress = new KeyPressEventHandler(control_KeyPress);
            this.CellMouseEnter -= new DataGridViewCellEventHandler(ExtendedDataGridView_CellMouseEnter);
            this.CellMouseEnter += new DataGridViewCellEventHandler(ExtendedDataGridView_CellMouseEnter);
            this.RowHeaderMouseClick += ExtendedDataGridView_RowHeaderMouseClick;
            isInitializing = false;
            Reset();
            #region Designer related code

            IServiceContainer serviceContainer = container as IServiceContainer;
            if (serviceContainer != null)
            {
                ExtendedDataGridViewPropertyFilter newMyFilter = new ExtendedDataGridViewPropertyFilter();
                DesignerActionService designerActionService = serviceContainer.GetService(typeof(DesignerActionService)) as DesignerActionService;
                //DesignerActionUIService designerActionUIService = serviceContainer.GetService(typeof(DesignerActionUIService)) as DesignerActionUIService;
                newMyFilter.oldService = (ITypeDescriptorFilterService)serviceContainer.GetService(typeof(ITypeDescriptorFilterService));
                newMyFilter.designerActionService = designerActionService;
                //newMyFilter.designerActionUIService = designerActionUIService;
                if (newMyFilter.oldService != null)
                {
                    serviceContainer.RemoveService(typeof(ITypeDescriptorFilterService));
                }

                serviceContainer.AddService(typeof(ITypeDescriptorFilterService), newMyFilter);
            }

            // Acquire a reference to IComponentChangeService
            //This service is used during design to make sure that we do not allow the user
            //to edit Columns properties when the grid is in MSFlexGrid compatibility
            IComponentChangeService changeService = container as IComponentChangeService;
            if (changeService != null)
            {
                changeEventHandler = new ComponentChangingEventHandler(changeService_ComponentChanging);
                changeService.ComponentChanging -= changeEventHandler;
                changeService.ComponentChanging += changeEventHandler;
            }
            #endregion
        }