public override void InitializeEditingControl(int rowIndex, object initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle) { base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle); Controls.TimeControl control = DataGridView.EditingControl as Controls.TimeControl; NjitTimeColumn column = (this.OwningColumn as NjitTimeColumn); foreach (var property in column.TimeControl.GetType().GetProperties()) { var attributes = property.GetCustomAttributes(typeof(System.ComponentModel.CategoryAttribute), true); if (attributes.Length == 1 && ((System.ComponentModel.CategoryAttribute)attributes[0]).Category == "Njit" && property.CanRead && property.CanWrite) { property.SetValue(control, property.GetValue(column.TimeControl, null), null); } } if (this.Value == null || this.Value == DBNull.Value) { control.Text = (this.OwningColumn as NjitTimeColumn).DefaultValue; } else { control.Text = this.Value.ToString(); } DataGridView.CellValidating += DataGridViewCellValidating; }
public override object Clone() { NjitTimeColumn copy = base.Clone() as NjitTimeColumn; foreach (var property in copy.GetType().GetProperties()) { var attributes = property.GetCustomAttributes(typeof(System.ComponentModel.CategoryAttribute), true); if (attributes.Length == 1 && ((System.ComponentModel.CategoryAttribute)attributes[0]).Category == "Njit" && property.CanRead && property.CanWrite) { property.SetValue(copy, property.GetValue(this, null), null); } } return(copy); }