I would like to be able to display a DateTimePicker
that has a default value of nothing, i.e. no date.
For example, I have a start date dtTaskStart
and an end date dtTaskEnd
for a task, but the end date is not known, and not populated initially.
I have specified a custom format of yyyy-MM-dd
for both controls.
Setting the value to null
, or an empty string at runtime causes an error, so how can I accomplish this?
I have considered using a checkbox to control the enabling of this field, but there is still the issue of displaying an initial value..
Edit:
Arguably a duplicate of the question DateTimePicker Null Value (.NET), but the solution I found for my problem is not a solution for that question, so I think it should remain here for others to find..
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…