We help IT Professionals succeed at work.

Configuring a DateTimePicker for time only

curiouswebster
curiouswebster used Ask the Experts™
on
I would like to use the DateTimePicker for time only, not the date. How can I do this?

Thanks!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
http://msdn.microsoft.com/en-us/library/system.windows.forms.datetimepicker(v=vs.85).aspx

you would have to set a custom format  

CustomFormat = "HHmm ss"

-dif
Commented:
If you want the DateTimePicker to only display Time you can set the Format property like this.
http://msdn.microsoft.com/en-us/library/ms229631.aspx

This JQuery code is a nice solution.
http://pttimeselect.sourceforge.net/example/index.html
curiouswebsterSoftware Engineer

Author

Commented:
I changed the format to Time, added your custom format, but still no change. 3:08:34 PM is shows. I do not want seconds.

Also, I need the drop down to go away.
curiouswebsterSoftware Engineer

Author

Commented:
Custom Format worked, but I need to change format to Custom, not Time, in addition to setting CustomFormat to HH:MM

Commented:
Select the DateTimePicker Object on your form, go to the properties and change the format to "time".
curiouswebsterSoftware Engineer

Author

Commented:
I can not get the AM and PM to show up. I guess I closed the question too early.  I assume I can use CustomFormat to include that.

Anybody got that correct format?
curiouswebsterSoftware Engineer

Author

Commented:
it's 'tt'