This project has moved. For the latest updates, please go here.

Null value in DateTimePicker

Apr 26, 2011 at 5:36 PM

I'm using the DateTimePicker value to show an optional date and time information. I'd like to be able to assign some kind of null value so the control will show nothing in the textbox. Is it possible to do that with the DateTimePicker? Or any workaround that could simulate what I need to do? Thanks!

Apr 27, 2011 at 2:40 AM

Yes, the Value property is of type Nullable<DateTime> (DateTime?).  If the Value is null nothing will show as long as you don't specify a Watermark.

Jun 29, 2012 at 5:12 AM

How do you deselect a date once one is selected? ie return to a NULL value?

Coordinator
Jul 3, 2012 at 2:01 PM

Hi,

 

If you set the DateTimePicker.Value property to "null", the date will be reset.  You may also delete the content of the TextBox.