Thursday 7 August 2008

Set a DateTimePicker to Blank

If you have ever had problems setting the text of a datetimepicker to blank (rather than the default value) then the following code example is the way to do it:

if (csMahService._EndDate.HasValue)
{
dtpEndDate.Value = csMahService._EndDate.Value;
}
else
{
dtpEndDate.CustomFormat = " ";
}

Note you have to set the Format property to Custom.

No comments:

Free Hit Counter