예제 #1
0
        /// <summary>
        /// Custom implementation of the <see cref="InitializeEditingControl"/> function.
        /// This function is called by the <see cref="DataGridView"/> control
        /// at the beginning of an editing session. It makes sure
        /// that the properties of the <see cref="ColorButton"/> editing control are
        /// set according to the cell properties.
        /// </summary>
        /// <param name="rowIndex">The zero-based row index of the cell.</param>
        /// <param name="initialFormattedValue">An <see cref="Object"/> that represents the value displayed by the cell when editing is started.</param>
        /// <param name="dataGridViewCellStyle">A <see cref="DataGridViewCellStyle"/> that represents the style of the cell.</param>
        public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
        {
            base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
            ColorDropdown colorDropdown = this.DataGridView.EditingControl as ColorDropdown;

            if (colorDropdown != null)
            {
                colorDropdown.CurrentColor = this._currentColor;
            }
        }
예제 #2
0
        /// <summary>
        /// Overridden. Unsubscribes events from the hosted control.
        /// </summary>
        /// <param name="c">control</param>
        protected override void OnUnsubscribeControlEvents(Control c)
        {
            // Call the base method so the basic events are unsubscribed.
            base.OnUnsubscribeControlEvents(c);

            // Cast the control to a ColorDropdown control.
            ColorDropdown colorDropdownControl = (ColorDropdown)c;

            // Remove the event.
            colorDropdownControl.ColorChanged -=
                new EventHandler(colorDropdownControl_ColorChanged);
        }
예제 #3
0
        /// <summary>
        /// Overridden. Subscribes events from the hosted control.
        /// </summary>
        /// <param name="c">control</param>
        protected override void OnSubscribeControlEvents(Control c)
        {
            // Call the base so the base events are connected.
            base.OnSubscribeControlEvents(c);

            // Cast the control to a ColorDropdown control.
            ColorDropdown colorDropdownControl = (ColorDropdown)c;

            // Add the event.
            colorDropdownControl.ColorChanged +=
                new EventHandler(colorDropdownControl_ColorChanged);
        }