RadDateTimePicker programmatically change Time scales

2 posts, 0 answers
  1. CreoniX
    CreoniX avatar
    28 posts
    Member since:
    Sep 2009

    Posted 03 Nov Link to this post

    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?

     

  2. Stefan Nenchev
    Admin
    Stefan Nenchev avatar
    279 posts

    Posted 07 Nov Link to this post

    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!
  3. UI for WPF is Visual Studio 2017 Ready
Back to Top