How to update TimeOnly from code in the datetimepicker

On Windows10 Xojo 2020r2.1 DateTimePicker
If I set the DateTimePicker to Time Only, How do I set the time in the datetimepicker from code. If I set it to a known datetime it does Not show the correct Time Only. If I change the datetimepicker to date and time then the time is shown correctly. I want to show the Time only and set it from code. Is that possible?

I am having the same issue. I hope someone can help answer.

I have found a work around.
it is ugly but it works.
Var SQLDateTime As String = “2019-08-01 06:00”
Var myDate1 As DateTime = DateTime.FromString(SQLDateTime)
OccTimeStart.DisplayMode = DesktopDateTimePicker.DisplayModes.DateAndTime
OccTimeStart.SelectedDate = myDate1
OccTimeStart.DisplayMode = DesktopDateTimePicker.DisplayModes.TimeOnly

There’s a bug. Even in 2021r3.1 changing SelectedDate does not refresh the display. So you are correct, you need to try to fire the display refresh by some alternative method, changing other properties that also affects the display.

This is enough for time:

Var theTime As String = "14:35:00"

DateTimePicker1.SelectedDate = Datetime.FromString(Datetime.Now.SQLDate+" "+theTime)
DateTimePicker1.DisplayMode = DesktopDateTimePicker.DisplayModes.TimeOnly
1 Like

Short and sweet I like it. Thanks.

1 Like