Click here to Skip to main content
14,355,411 members

.NET TimePicker

Rate this:
4.20 (39 votes)
Please Sign up or sign in to vote.
4.20 (39 votes)
27 Jun 2007
A variation on the standard .NET date-time picker

Image 1


Did you ever used the DateTimePicker that comes with .NET? If so, you must appreciate the easy to use drop down calendar where you click on the date that you need. You can even navigate the months and the years very easily at the top of its panel. Every user that I know just loves this component.

The DateTimePicker can also be converted in a TimePicker. Unfortunately, I've never been satisfied with this TimePicker since it uses a numeric up-down control to select your time. There is no drop down feature. The user must manually type in his/her time and that has always bothers me. I asked myself if there could be an easier way to select a time.

With my TimePicker, this problem is solved. The TimePicker shows a drop down panel very similar to the DateTimePicker. Instead of having dates, you have hours and minutes on the panel. You click on the time that you want and then click outside of the panel to see the time being assigned to the TimePicker control.

TimePicker v2 finally complete

After 4 years, I finally decided to update the TimePicker. Based on the comments, it had a few bugs in it. I took the time to fix some of them and added a few new features to it. I tried to keep the same functionalities to avoid any breaking changes. If I broke something, I'm sorry. For people who would like a TimePicker for .NET 3.0 or on Vista, I haven't worked with those technologies (yet). Try it out and let me know.

New feature

  • KeyToHidePicker is a new property on the TimePicker. Assign a keyboard key to hide the picker. This is useful for people who want to hide the picker from the keyboard instead of clicking somewhere else. The default key is Esc.
  • Increasing the font size will make the control bigger. Earlier versions weren't doing this. Drop down button and check box will also resize.
  • Added the TimeChangeEventArgs class. When the Value property of the TimePicker changes, an event is launched with an instance of TimeChangeEventArgs. It holds the previous TimeSpan value and the new value. This might be the only breaking change. In the previous version, I was passing an EventArgs object.
  • When the check box is visible, it controls the enable or disable state of the time. When check box is not visible, the Enable property of the TimePicker controls the state of the TimePicker.


  • I paint the time instead of using .NET controls. This gave me more control.
  • The minutes are now drawn correctly when TimePicker is in a tab page.
  • The separator between the hours and minutes is drawn correctly.
  • Refactored the code to make it more .NET 2.0. The classes are now partial with the UI components in their own separate file.
  • Changed the drop down arrow to look more like the one in the DateTimePicker.

How to install?

Simply add the DLL to the Visual Studio .NET toolbox. You will see an item named TimePicker at the very end. Just drag and drop this component on your form and you are ready to use the TimePicker.

How it works?

You simply click on the drop down arrow on the right side of the component to set the desired time. You then call the Value property to get that time. I use a TimeSpan to hold the time since the .NET Framework already has a structure to handle time values.

If you want a string representation of your time, you can use the ToString methods implemented in the TimePicker or you can throw back the TimeSpan in a DateTime structure and call its ToString which has a lot of predefined format.

Useful properties

TimePicker has a few interesting properties that I have added. Read the following to know how you can customize the TimePicker the way you want.


You can choose the color of your choice for the buttons. This color will go on the buttons that are not selected.


Property that returns the state of the checkbox of the control


A string that is parsed by the TimePicker. The format is responsible for displaying the time in the TimePicker control.


Change this property if you want the time to be on the right side of your TimePicker.

Image 2


A boolean value to place a checkbox on the left side of the control. Clicking in the checkbox will enable the rest of the control.

Image 3


A boolean value that makes the arrow on the right side of the component disappear. Since the user can click on the hours or the minutes, some developers might want to hide the drop down arrow.

Image 4


You can choose the color of your choice for the buttons that are selected.


A character is inserted here. Based on the preference of the developer, you can separate the hours from the minutes with any character that you want.


Don't confuse this property with Separator, they are not related. SeparatorColor is a color used to separate the hours from the minute in the panel. If you change the colors of the buttons with ButtonColor and SelectedColor, you might want to harmonize the display by choosing a color for the separator.


An enum that changes the mode of the TimePicker. If you only want the hours to be displayed in the TimePicker, set this property to Hours. If you also want the minutes, select the Minutes value and if you want both, choose HoursAndMinutes. For people who want to use TimePicker to pick seconds, just use the Minutes value and place a label next to it called Seconds.

Image 5


The Value property is a TimeSpan structure. It holds the time that you have set with the user interface. You can change it with my very own TimePicker interface by clicking on it like in the picture below.

Image 6


  • You can change the Value property with my very own TimePicker. Since the TimePicker is shown in modal mode, you have to click on the separator to hide the form.
  • Instead of always clicking the drop down arrow, you can click directly the hours or the minutes.
  • Don't bother to change the format string if you change the separator. My component will update itself when you change a property.
  • If you only want to see the hours in the TimePicker, change the TimeSelector property to Hours. The same goes for the minutes.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Louis-Philippe Carignan
Web Developer
Canada Canada
I'm a software engineer with 5 years of experience. I've been writting code mostly in .NET. My fields of expertise revolves around Windows Forms, Remoting, Xml, database connectivity, CompactFramework and GIS applications.

I'm an early adopter of Test Driven Developpement and Continuous Integration. I worked with tools such as Test Driven .NET, Cruise Control .NET, NAnt, NUnit and NCover. I am involved with the Agile user group in my city. My main area of interest is with lean software development but I do value other methodologies as well.

You can read my blog about lean software. It's mostly in French but I do have a few posts in English.

I'm always open to job offers. I am open to senior software engineer or achitect positions. If you are looking for someone with my profile, send me an e-mail. I am willing to relocate.

Comments and Discussions

GeneralMy vote of 5 Pin
Mojtaba Rezaeian30-Sep-11 6:25
memberMojtaba Rezaeian30-Sep-11 6:25 
Questionuse in web project Pin
monu nair29-Sep-11 6:05
membermonu nair29-Sep-11 6:05 
GeneralWill it work with an ASP.NET page? thanks! Pin
maximus.dec.meridius11-Oct-10 12:57
membermaximus.dec.meridius11-Oct-10 12:57 
QuestionHow to download the time picker installer? Pin
atinfatima10-Oct-10 0:03
memberatinfatima10-Oct-10 0:03 
GeneralPicking seconds doesn't work. Pin
sss_golovko13-Mar-09 3:02
membersss_golovko13-Mar-09 3:02 
GeneralRe: Picking seconds doesn't work. Pin
Louis-Philippe Carignan16-Mar-09 17:54
memberLouis-Philippe Carignan16-Mar-09 17:54 
GeneralRe: Picking seconds doesn't work. Pin
sss_golovko17-Mar-09 9:30
membersss_golovko17-Mar-09 9:30 
Generaltimepicker installation problem Pin
floko11-Nov-08 4:49
memberfloko11-Nov-08 4:49 
GeneralRe: timepicker installation problem Pin
Louis-Philippe Carignan12-Nov-08 2:14
memberLouis-Philippe Carignan12-Nov-08 2:14 
AnswerProperly show hours(0-23) and minutes(0-59) in .net2.0 vs2005 Pin
SimeonVelichkov24-Jun-08 3:59
memberSimeonVelichkov24-Jun-08 3:59 
GeneralRe: Properly show hours(0-23) and minutes(0-59) in .net2.0 vs2005 Pin
ehrenberg20-Nov-08 2:41
memberehrenberg20-Nov-08 2:41 
GeneralTimeSpan greater than 24 hours Pin
Michael Kämpf7-Apr-08 0:07
memberMichael Kämpf7-Apr-08 0:07 
GeneralI used listboxes Pin
trantrum27-Jan-08 8:55
professionaltrantrum27-Jan-08 8:55 
QuestionApp on Second Monitor Control Paints on First Monitor Pin
lodlaiden14-Aug-07 13:12
memberlodlaiden14-Aug-07 13:12 
QuestionFontsize problem Pin
Christoph Herrmann1-Jul-07 23:47
memberChristoph Herrmann1-Jul-07 23:47 
AnswerRe: Fontsize problem Pin
Louis-Philippe Carignan2-Jul-07 4:41
memberLouis-Philippe Carignan2-Jul-07 4:41 
AnswerRe: Fontsize problem Pin
Christoph Herrmann2-Jul-07 5:15
memberChristoph Herrmann2-Jul-07 5:15 
GeneralRelated TimePicker Pin
Vasudevan Deepak Kumar28-Jun-07 0:02
memberVasudevan Deepak Kumar28-Jun-07 0:02 
GeneralRe: Related TimePicker Pin
Louis-Philippe Carignan28-Jun-07 13:09
memberLouis-Philippe Carignan28-Jun-07 13:09 
GeneralNice, but.... Pin
Jose Menendez Póo27-Jun-07 12:21
memberJose Menendez Póo27-Jun-07 12:21 
GeneralVery Cool Pin
merlin98127-Jun-07 11:52
professionalmerlin98127-Jun-07 11:52 
GeneralTimePicker - Plz Help Me.... Pin
Veesam Suresh Kumar11-Jun-07 20:22
memberVeesam Suresh Kumar11-Jun-07 20:22 
QuestionHow user can exit from time picker only using keyboard? Pin
Emil15006-May-07 21:08
memberEmil15006-May-07 21:08 
AnswerRe: How user can exit from time picker only using keyboard? Pin
Louis-Philippe Carignan7-May-07 12:13
memberLouis-Philippe Carignan7-May-07 12:13 
GeneralRe: How user can exit from time picker only using keyboard? Pin
Emil150013-May-07 1:23
memberEmil150013-May-07 1:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Posted 7 Jul 2003


84 bookmarked