Display `00` instead of `0` in a NumericUpDown control

Clément picture Clément · Aug 17, 2010 · Viewed 14.2k times · Source

I'm letting users select a date/time for a scheduled task to run, using two NumericUpDowncontrols.

I'd like one-digit values to be padded with a leading 0, so as to display 09:00 instead of 9:0.

Answer

Clément picture Clément · Feb 17, 2011

The definitive solution is to use a DateTimePickerwith ShowUpDown set to True and Format set to Time or Custom. In the latter case, you'd use hh:mm or HH:mm as a custom format.