예제 #1
0
        /// <summary>
        /// Raises the MouseDown event
        /// </summary>
        /// <param name="e">A CellMouseEventArgs that contains the event data</param>
        public override void OnMouseDown(CellMouseEventArgs e)
        {
            base.OnMouseDown(e);

            if (this.ShowDropDownButton || (e.Table.IsEditing && e.CellPos == e.Table.EditingCell))
            {
                if (e.Table.IsCellEditable(e.CellPos))
                {
                    // get the button renderer data
                    DropDownRendererData rendererData = this.GetDropDownRendererData(e.Cell);

                    if (this.CalcDropDownButtonBounds().Contains(e.X, e.Y))
                    {
                        if (!(e.Table.ColumnModel.GetCellEditor(e.CellPos.Column) is DropDownCellEditor))
                        {
                            throw new InvalidOperationException("Cannot edit Cell as DropDownCellRenderer requires a DropDownColumn that uses a DropDownCellEditor");
                        }

                        rendererData.ButtonState = ComboBoxStates.Pressed;

                        if (!e.Table.IsEditing)
                        {
                            e.Table.EditCell(e.CellPos);
                        }

                        ((IEditorUsesRendererButtons)e.Table.EditingCellEditor).OnEditorButtonMouseDown(this, e);

                        e.Table.Invalidate(e.CellRect);
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Gets the DropDownRendererData specific data used by the Renderer from
        /// the specified Cell
        /// </summary>
        /// <param name="cell">The Cell to get the DropDownRendererData data for</param>
        /// <returns>The DropDownRendererData data for the specified Cell</returns>
        protected DropDownRendererData GetDropDownRendererData(Cell cell)
        {
            object rendererData = this.GetRendererData(cell);

            if (rendererData == null || !(rendererData is DropDownRendererData))
            {
                rendererData = new DropDownRendererData();

                this.SetRendererData(cell, rendererData);
            }

            return((DropDownRendererData)rendererData);
        }
예제 #3
0
        /// <summary>
        /// Raises the MouseUp event
        /// </summary>
        /// <param name="e">A CellMouseEventArgs that contains the event data</param>
        public override void OnMouseUp(CellMouseEventArgs e)
        {
            base.OnMouseUp(e);

            if (this.ShowDropDownButton || (e.Table.IsEditing && e.CellPos == e.Table.EditingCell))
            {
                if (e.Table.IsCellEditable(e.CellPos))
                {
                    // get the renderer data
                    DropDownRendererData rendererData = this.GetDropDownRendererData(e.Cell);

                    if (this.CalcDropDownButtonBounds().Contains(e.X, e.Y))
                    {
                        rendererData.ButtonState = ComboBoxStates.Hot;

                        e.Table.Invalidate(e.CellRect);
                    }
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Raises the MouseLeave event
        /// </summary>
        /// <param name="e">A CellMouseEventArgs that contains the event data</param>
        public override void OnMouseLeave(CellMouseEventArgs e)
        {
            base.OnMouseLeave(e);

            if (this.ShowDropDownButton || (e.Table.IsEditing && e.CellPos == e.Table.EditingCell))
            {
                if (e.Table.IsCellEditable(e.CellPos))
                {
                    // get the button renderer data
                    DropDownRendererData rendererData = this.GetDropDownRendererData(e.Cell);

                    if (rendererData.ButtonState != ComboBoxStates.Normal)
                    {
                        rendererData.ButtonState = ComboBoxStates.Normal;

                        e.Table.Invalidate(e.CellRect);
                    }
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Raises the MouseMove event
        /// </summary>
        /// <param name="e">A CellMouseEventArgs that contains the event data</param>
        public override void OnMouseMove(CellMouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (this.ShowDropDownButton || (e.Table.IsEditing && e.CellPos == e.Table.EditingCell))
            {
                if (e.Table.IsCellEditable(e.CellPos))
                {
                    // get the button renderer data
                    DropDownRendererData rendererData = this.GetDropDownRendererData(e.Cell);

                    if (this.CalcDropDownButtonBounds().Contains(e.X, e.Y))
                    {
                        if (rendererData.ButtonState == ComboBoxStates.Normal)
                        {
                            if (e.Button == MouseButtons.Left && e.Row == e.Table.LastMouseDownCell.Row && e.Column == e.Table.LastMouseDownCell.Column)
                            {
                                rendererData.ButtonState = ComboBoxStates.Pressed;
                            }
                            else
                            {
                                rendererData.ButtonState = ComboBoxStates.Hot;
                            }

                            e.Table.Invalidate(e.CellRect);
                        }
                    }
                    else
                    {
                        if (rendererData.ButtonState != ComboBoxStates.Normal)
                        {
                            rendererData.ButtonState = ComboBoxStates.Normal;

                            e.Table.Invalidate(e.CellRect);
                        }
                    }
                }
            }
        }
		/// <summary>
		/// Gets the DropDownRendererData specific data used by the Renderer from 
		/// the specified Cell
		/// </summary>
		/// <param name="cell">The Cell to get the DropDownRendererData data for</param>
		/// <returns>The DropDownRendererData data for the specified Cell</returns>
		protected DropDownRendererData GetDropDownRendererData(Cell cell)
		{
			object rendererData = this.GetRendererData(cell);

			if (rendererData == null || !(rendererData is DropDownRendererData))
			{
				rendererData = new DropDownRendererData();

				this.SetRendererData(cell, rendererData);
			}

			return (DropDownRendererData) rendererData;
		}