How to stop DateTimePicker from showing the current date

Each time I run my program, DateTimePicker automatically shows the date and time. How can i stop this? How can I make it empty?

I have a DOB DateTimePicker. For some users, I don’t know their DOB, so I would like DateTimePicker to display a blank or empty field.

+4
source share
7 answers

I don't think there is a way to make it empty, but you can use the ShowCheckBox and Checked properties for true. DateTimePicker will then have a checkbox in addition to the drop-down date. Date highlighting is disabled if not checked. This allows you to have "no value" or null for the DOB if the check box is not selected.

+2
source

Set DateTimePicker.CustomFormat = " " Make sure there is a space. This will display as empty space.

I used DataRowView drv = DBBindingSource(DB) . together with a control instruction to set the value to zero when necessary.

 if(drv.Row["DOB"] == DBNull.Value) { DateTimePicker.CustomFormat = " "; } else { DateTimePicker.CustomFormat = "dd MMMM yyyy"; } 
+5
source

See this CodeProject article on the Nullable DateTimePicker . It is inherited from DateTimePicker .

+1
source

Use this:

 Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged DateTimePicker1.Value = DateTimePicker1.Value.Today End Sub 
+1
source

Set the Value property to the date you want.

0
source

if you are talking about datetimepicker from Trent Richardson look at this topic fooobar.com/questions/1349786 / ...

basically set the value of the input field in the onClose event.

 $('input.datetime').datetimepicker({ onClose: function (value) { $('input.datetime').val(value); } }); 
0
source

my decision:

 Public Sub ClearDatePicker(ByVal DatePicker As DateTimePicker) DatePicker.CustomFormat = " " DatePicker.Format = DateTimePickerFormat.Custom End Sub 

then the datetimepicker will be displayed empty.

0
source

All Articles