Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Friends,

I have to m,ake an app in which i have schedule it for the selected day on particular time in every week, for this i am making a windows form for the user in which they can select the day and time of day..
For this i am using numericupdown control but dont have any idea for how to use it for time...
Posted

1 solution

A NumericUpDown control is probably a poor choice for this, unless you are just trying to pick an hour between 1 and 12 inclusive, in which case it's trivial - so I suspect that you want something more complicated, such as AM / PM or hour and minutes, and so forth.

If that is the case, why not use a DateTimePicker instead? It allows you to specify the Format as Time, and disable the calendar button to show an up / down button instead.
Just set the properties in teh designer:
Format       Time
ShowUpDown   true
or
Format          Custom
CustomFormat    hh:mm
ShowUpDown      true
If you aren't interested in seconds.
 
Share this answer
 
Comments
abhishekagrwl25 18-May-13 5:05am    
Thanks for the solution, yes i am not interested in seconds but i have to show AM/PM..
what value is to be there in CustomFormat property for that...??
Member 12394679 8-Feb-17 0:09am    
@OrignalGriff , I'd like to accomplish a similar thing, but the problem I'm finding with the DateTimePicker is that there is no such thing as a "negative date". I'd like to be able to display "-5:00" (-5 hours). I don't care about seconds or am/pm here.

So I believe abhishekagrwl25's question remains: is there a way to use NumericUpDown for time selection?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900