/// <summary> /// Initialize Editing Control, control type is AIDataGridViewDateTimePickerEditingControl. /// </summary> /// <param name="rowIndex"></param> /// <param name="initialFormattedValue"></param> /// <param name="dataGridViewCellStyle"></param> public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle) { // Set the value of the editing control to the current cell value. try { base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle); string typeOfValue = string.Empty; IType type = this.Tag as IType; if (type == null || type.IsNullable) { type = this.DataGridView.Rows[rowIndex].Cells[Constants.QUERY_GRID_FIELDTYPE_DISPLAY_HIDDEN].Value as IType; } if (type.IsNullable) { typeOfValue = CommonValues.GetSimpleNameForNullable(type.FullName); } else { typeOfValue = type.DisplayName; } // } if (typeOfValue == typeof(System.DateTime).ToString() || (type != null && type.IsSameAs(typeof(DateTime)))) { dbDataGridViewDateTimePickerEditingControl ctl = DataGridView.EditingControl as dbDataGridViewDateTimePickerEditingControl; if (this.Value != null && this.Value != this.OwningColumn.DefaultCellStyle) { try { DateTimeFormatInfo dateTimeFormatterProvider = DateTimeFormatInfo.CurrentInfo.Clone() as DateTimeFormatInfo; dateTimeFormatterProvider.ShortDatePattern = "MM/dd/yyyy hh:mm:ss tt"; DateTime dateTime = DateTime.Parse(Value.ToString(), dateTimeFormatterProvider); ctl.Value = dateTime; } catch (Exception ex) { ex.ToString(); ctl.Value = System.DateTime.Now; } } } else if (typeOfValue == typeof(System.Boolean).ToString() || (type != null && type.IsSameAs(typeof(Boolean)))) { //intializing editing control (DataGridViewComboBoxEditingControl) DataGridViewComboBoxEditingControl ctl = this.DataGridView.EditingControl as DataGridViewComboBoxEditingControl; //setting combox style ctl.DropDownStyle = ComboBoxStyle.DropDownList; ctl.FlatStyle = FlatStyle.Popup; FillBoolColumnValue(ctl); if (this.Value != null && this.Value != this.OwningColumn.DefaultCellStyle) { try { ctl.EditingControlFormattedValue = this.Value.ToString(); } catch (Exception ex) { ex.ToString(); ctl.SelectedItem = ctl.Items[0].ToString(); } } ctl.Width = this.OwningColumn.Width; } } catch (Exception oEx) { string str = oEx.Message; } }