DateTime Picker In WinForm How To Pick Time?

sooprise picture sooprise · Sep 16, 2010 · Viewed 58.7k times · Source

Possible Duplicate:
DateTimePicker: pick both date and time

I'm using a WinForm DateTime picker and it does a fantastic job of choosing dates, but I don't know how to do times. It looks like a time is associated with the value, so maybe there's a way to use this to pick a time?

If there is no built in way to do this, I'll just create another box for the time and modify the DateTime value from the DateTime picker.

Thanks!

Answer

Doug picture Doug · Sep 16, 2010

You can use the built in DateTime picker by adding a custom format string as follows:

DateTimePicker.ShowUpDown = true;
DateTimePicker.CustomFormat = "hh:mm";
DateTimePicker.Format = System.Windows.Forms.DateTimePickerFormat.Custom;

Enjoy!