cnnc = DataGridView.EditingControl as CalendarEditingControl;
dgvc = this.OwningColumn;
if (dgvc is CalendarColumn)
{
cnncl = dgvc as CalendarColumn;
cnnc.Value = (this.Value != null) ? DateTime.Parse(this.Value.ToString()) : DateTime.Now;
}
}
public override Type EditType
{
get
{
return typeof(CalendarEditingControl);
}
}
}
public class CalendarColumn : DataGridViewColumn
{
public CalendarColumn()
: base(new CalendarCell())
{
}
public override DataGridViewCell CellTemplate
{
get
{
return base.CellTemplate;
}
set
{
// Only cell types that derive from CalendarCell are supported as the cell template.
if (value != null && !value.GetType().IsAssignableFrom(typeof(CalendarCell)))
{
string s = "Cell type is not based upon the CalendarCell.";//CustomColumnMain.GetResourceManager().GetString("excNotCalendar");
throw new InvalidCastException(s);
}
base.CellTemplate = value;
}
}
}
public class CalendarEditingControl : DateTimePicker, IDataGridViewEditingControl
{
protected int rowIndex;
protected DataGridView dataGridView;
protected bool valueChanged = false;