1

I need to find a way to show empty value for a DateTimePicker which is in a time format. I searched for this question, then I found the examples for custom formatted DateTime Pickers (using this: DateTimePickerFormat.Custom). But I need to use DateTimePickerFormat.Time format in the code.

The detail for the component that I am using is like that:

DateTimePicker dtptime = new DateTimePicker();
dtptime.Format = DateTimePickerFormat.Time;

I used this code, but that does not work:

dtptime.CustomFormat = " ";

In this question Set DateTimePicker value to be null , I couldn't find an answer to Time formatted DateTimePicker.

Tunahan
  • 303
  • 4
  • 22
  • I already saw that question. But, I couldn't find a way to solve this issue for DateTimePickerFormat.Time formatting. – Tunahan Feb 06 '18 at 14:28
  • 1
    Merhaba Tunahan, unfortunately DateTimePicker control before or after .Net has never been a good control for time only values. If you would use that, then the only way is to enable checkbox and use it unchecked to mean an "empty" value (a peculiar way to support null). Maybe you should create your own textbox based control instead. IMHO an easier way is to allow free entry in a textbox and validate afterwards (or as typed). Such a custom textbox could extend valid times with strings such as now, 1 hr ago etc for more flexibility. – Cetin Basoz Feb 06 '18 at 14:37
  • I think this is not a duplicate question as it is mentioned. – Tunahan Feb 07 '18 at 05:08
  • Thanks for the advice. It seems that I will try to implement a custom textbox like you said. @CetinBasoz – Tunahan Feb 07 '18 at 05:11

0 Answers0