Hi Martin,
You need to handle CurrentCellValidating and DrawCellDisplayText events to solve this issue. In currentCellValidating event, you should assign the Renderer.ControlValue to DateTime.MinValue if the ControlText is String.Empty and store the current cell location in Hashtable. In DrawCellDisplayText event, you need check the cell location with that Hashtable, if it presents then set e.DisplayText to String.Empty. Here is the sample code that shows this task.
void gridDataBoundGrid2_DrawCellDisplayText(object sender, GridDrawCellDisplayTextEventArgs e)
{
int RowIndex = e.Style.CellIdentity.RowIndex;
int ColIndex = e.Style.CellIdentity.ColIndex;
if (EmptyDateCell.Contains(GetHashCode(RowIndex, ColIndex)))
{
bool eValue = (bool)EmptyDateCell[GetHashCode(RowIndex, ColIndex)];
if (eValue)
{
e.DisplayText = String.Empty;
}
}
}
Hashtable EmptyDateCell = new Hashtable();
void gridDataBoundGrid2_CurrentCellValidating(object sender, CancelEventArgs e)
{
GridDataBoundGrid grid = sender as GridDataBoundGrid;
GridCurrentCell cc = grid.CurrentCell;
if (grid.Binder.InternalColumns[cc.ColIndex - 1].MappingName == "OrderDate" || grid.Binder.InternalColumns[cc.ColIndex - 1].MappingName == "RequiredDate" || grid.Binder.InternalColumns[cc.ColIndex - 1].MappingName == "ShippedDate")
{
if (cc.Renderer.ControlText == String.Empty)
{
cc.Renderer.ControlValue = DateTime.MinValue;
grid.Model[cc.RowIndex, cc.ColIndex].CellValue = DateTime.MinValue;
EmptyDateCell[GetHashCode(cc.RowIndex, cc.ColIndex)] = true;
grid.Binder.EndEdit();
}
else
{
EmptyDateCell[GetHashCode(cc.RowIndex, cc.ColIndex)] = false;
}
}
}
private string GetHashCode(int RowIndex, int ColIndex)
{
return "#" + RowIndex + "#-#" + ColIndex + "#";
}
Sample:
http://websamples.syncfusion.com/samples/Grid.Windows/F73126/main.htmPlease let me know if this helps.
Best Regards,
Srirajan