public override object Clone()
        {
            DateTimeTextBoxDataGridViewColumn column = (DateTimeTextBoxDataGridViewColumn)base.Clone();

            column.Format       = Format;
            column.CustomFormat = CustomFormat;

            return(column);
        }
        protected override object GetFormattedValue(object value, int rowIndex, ref DataGridViewCellStyle cellStyle, System.ComponentModel.TypeConverter valueTypeConverter, System.ComponentModel.TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context)
        {
            object             myValue = value;
            DataGridViewColumn dgvc    = this.OwningColumn;

            if (dgvc is DateTimeTextBoxDataGridViewColumn)
            {
                DateTimeTextBoxDataGridViewColumn rtvc = dgvc as DateTimeTextBoxDataGridViewColumn;
                this.Format       = rtvc.Format;
                this.CustomFormat = rtvc.CustomFormat;
                this.Style.Format = rtvc.CustomFormat;
                DateTime dt = Convert.ToDateTime(value);
                if (rtvc.CustomFormat != "")
                {
                    myValue = dt.ToString(CustomFormat);
                }
            }
            return(base.GetFormattedValue(myValue, rowIndex, ref cellStyle, valueTypeConverter, formattedValueTypeConverter, context));
        }
        public override void InitializeEditingControl(int rowIndex, object
                                                      initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
        {
            DateTimeTextBoxDataGridViewControl ctl =
                DataGridView.EditingControl as DateTimeTextBoxDataGridViewControl;

            ctl.Text = (initialFormattedValue is System.DBNull) ? string.Empty : (string)initialFormattedValue;
            DataGridViewColumn dgvc = this.OwningColumn;

            if (dgvc is DateTimeTextBoxDataGridViewColumn)
            {
                DateTimeTextBoxDataGridViewColumn rtvc = dgvc as DateTimeTextBoxDataGridViewColumn;
                ctl.Format        = rtvc.Format;
                ctl.CustomFormat  = rtvc.CustomFormat;
                this.Style.Format = rtvc.CustomFormat;
            }

            // Set the value of the editing control to the current cell value.
            base.InitializeEditingControl(rowIndex, initialFormattedValue,
                                          dataGridViewCellStyle);
        }