This is a migrated thread and some comments may be shown as answers.

RadDateTimePicker programmatically change Time scales

1 Answer 225 Views
DateTimePicker
This is a migrated thread and some comments may be shown as answers.
JIG
Top achievements
Rank 1
JIG asked on 03 Nov 2016, 04:58 PM

Hi, 

Is it possible when using the standard DateTimePicker to dynamically change the StartTime/EndTime properties of the Time-part of the control?

I would like the user to be able to click f.ex. 9:00 in the TimePicker, after which this same Time-picker part displays 9:05, 9:10, 9:15, 9:20... until 10:00

(a bit the same like for the Date-picker part - where you can choose the year, then month, then date ....)

Is that something that can be done?

 

1 Answer, 1 is accepted

Sort by
0
Stefan Nenchev
Telerik team
answered on 07 Nov 2016, 12:25 PM
Hi,

You can consider utilizing the SelectionChanged event of the RadDateTimePicker control and manually add set the StartTime and EndTime properties according to the selected hour:

private void RadDateTimePicker_SelectionChanged(object sender, SelectionChangedEventArgs e)
      {
          var selectedHour = ((DateTime)e.AddedItems[0]).Hour;
 
          this.RadDateTimePicker.StartTime = new TimeSpan(selectedHour,0,0);
          this.RadDateTimePicker.TimeInterval = new TimeSpan(0, 5, 0);
          this.RadDateTimePicker.EndTime = new TimeSpan(selectedHour + 1, 0, 0);
      }

 Of course, you might need to further consider the exact approach according to your setup. I suggest you have a look at the following article from our documentation - Clock Items - as setting a custom ClockItemsSource should be useful for you.

Regards,
Stefan Nenchev
Telerik by Progress
Do you need help with upgrading your WPF project? Try the Telerik API Analyzer and share your thoughts!
Tags
DateTimePicker
Asked by
JIG
Top achievements
Rank 1
Answers by
Stefan Nenchev
Telerik team
Share this question
or