Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
505
quick advice needed on UltraDateTimeEditor format and maskinput
posted

I have been using the Windows DateTimePicker to display a time only and allow the user to spin the time.

The key is to just have a line like ctrl.CustomFormat = "HH:mm".  The only problem with this is that I have to have a time present in the control at startup.  I'd prefer to have it blank until the user starts hitting the up/down buttons.

Can I use the UltraDateTimeEditor for this purpose?  I would think so, I have already started the process.  I am using a FormatString of hh:mm and a MaskInput of {time}. The Value, I leave blank. I have set the spin button style to "Always". All picked on designer.  However, I have a few minor issues:

1.  Can I get rid of the dropdown button?  I don't need it.

2. The spinning doesn't work quite like the DateTimePicker.  When you spin to 12 (on the hours for example) it stops rather than cyle to 1. Is there a way to duplicate the behaviro

3. With the Value not set, it displays as blank.  That's fine (and exactly what I want!), but when you hit the spin button, only the hours part comes up. Then you have to do hours minutes and am/pm. It would be nicer if the first time the spin button was hit, it went straight to some time (like 08:00 AM).  Can I do this?

4. When you're not editing the control, it doesn't display the AM or PM. I assume the formatstring can be modified to show this?

 

Thanks,

Andrew

Parents
  • 69832
    Suggested Answer
    Offline posted

    1. Set DropDownButtonDisplayStyle to 'Never'

    2. Set SpinWrap to true

    3. Not intrinsically; the only solution I can think of would be to maintain an external variable that tracks whether the button has ever been clicked.

    4. You used the uppercase "H", which denotes 24-hour time; if you use the lowercase "h", it will display as 12-hour time, and then you use the "t" format specifier to make the AM/PM appear. See here for MSDN documentation on format specifiers.

Reply Children