Setting DateTimePicker to Null

user2749421 picture user2749421 · Sep 12, 2013 · Viewed 14.5k times · Source

I am unable to set the set the Datetimepicker to Null, how can do it. In my project my requirement is to validate the DTPif it is a null, for that I need to set to Null, The code I am using is:

              {
                dateInsert.Format = DateTimePickerFormat.Custom;
                dateInsert.Text = string.Empty;
               }

Answer

karthik reddy picture karthik reddy · Sep 12, 2013

Use the following code:

dateTimePicker1.Format = DateTimePickerFormat.Custom;
dateTimePicker1.CustomFormat = " ";