Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Microsoft Date Time Picker Control

Status
Not open for further replies.

ugagrad

Programmer
Sep 12, 2003
49
US
Hello all,
I am attempting to use a date time picker control for an application I am creating. I was wondering if anyone knew of a way to set the minutes interval on that control. Currently the only thing it will do is go up by one minute with each click. I want to increment by 10 minutes or 15 minutes for example. Also, the default format is HH:MM:SS AM/PM. I was trying to get the format to HH:MM AM/PM. Does anyone have any suggestions.

Thanks in advance.
 

For the display format in the control, this comes from your Regional Settings in the control panel. Set the time format to HH:MM, you should get the result you need.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
ReFox XI (www.mcrgsoftware.com)
 

To change the increment, try writing code in the control's Change event. This is fired whenever the user interactively changes the time, either by typing or by clicking on one of the arrow buttons.

You might be able to do something like adding 10 or 15 to the Minute property. It's probably a bit more complicated than that, so you might have to experiment.

As for the format, Mike Gagnon suggested you use the Windows control panel setting, which might well be the best way. But you can also set the control's CustomFormat property.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike,

As far as I could tell, the CustomFormat only applied to dates, not time format.

The control's documentation (at msdn2.microsoft.com/en-us/library/
system.windows.forms.datetimepicker.customformat.aspx) lists the control characters for CustomFormat, and these include h (hours in 12-format), H (hours in 24-hour format), m (minutes) and so on.

On the other hand, it may be that these only apply when you are displaying a datetime, rather than a time on its own. Obviously, some experimentation is needed.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top