Allow Null Values in DataGridView Cells

Mar 1 2008 5:55 AM

I am using the Microsoft solution for adding colum of type CalendarColumn from http://msdn2.microsoft.com/en-us/library/7tas5c80(vs.80).aspx

However my date field allow null values, thus I had to add the line in red in order to allow the null values to be loaded

public override void InitializeEditingControl(int rowIndex, object
initialFormattedValue, DataGridViewCellStyle dataGridViewCellStyle)
{
// Set the value of the editing control to the current cell value.
base.InitializeEditingControl(rowIndex, initialFormattedValue, dataGridViewCellStyle);
CalendarEditingControl ctl = DataGridView.EditingControl as CalendarEditingControl;
if (this.Value != DBNull.Value)
     ctl.Value = (
DateTime)this.Value;
}

My problem is when I select a date value for a certain cell then I want to ignore this selction . i.e retrieve back the null value, I am not able to.

Is there a way to restore the null values when neede