I am developing a WinForms UI with two DateTimePicker
controls. Initially I want to set the value of the controls to null until a user selects a date. If the us
Let suppose dtpStartDate
is your DateTimePicker control.
Write this code in Page_Load-
`dtpStartDate.Format = DateTimePickerFormat.Custom;
dtpStartDate.CustomFormat = " ";`
Write this code in Value_Changed event-
`startDate = Convert.ToString(dtpStartDate.Value);
dtpStartDate.Format = DateTimePickerFormat.Short;`
here selected 'short' as Format. You can select 'Long' and other option available.
May be you need to create a UserControl withe the Appereance of a TextBox,and when the user click on a Calender Show, when you select a Date set it to the TextBox. It will allow nulls values.
The DateTimePicker does not allow null.