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

Make time unselectable in RadDateTimePicker's time pop window

1 Answer 362 Views
DateTimePicker
This is a migrated thread and some comments may be shown as answers.
Shoukat
Top achievements
Rank 1
Shoukat asked on 01 Jul 2015, 12:02 PM

Hi,

Is there a way to disable or make time unselectable in the Calendar's time pop window.

My requirement is I have RadDateTimePicker control for From and To dates. When I select From date & time, the selectable date & time in To date-time control should be the value greater than or equal to From date-time value. 

Currently I have achieved it partially using SelectableDateStart property. Using this property I can control only dates but not time.

For example,

I select From date & time as 15-07-2015, 11:30 respectively. Now in the To date-time control the selectable dates are 15-07-2015 and above. It won't allow the user to select date preceding 15-07-2015.

But the Time preceding 11:30 should be made unselectable which I am unable to achieve.

Can you please help me with this.

 

I am new to this forum and to WPF development. I'm sorry If I missed out some standard of creating new thread in the forum.

 

Thanks in advance.

 

Best Regards,

Shoukat

1 Answer, 1 is accepted

Sort by
0
Geri
Telerik team
answered on 06 Jul 2015, 11:17 AM
Hi Shoukat,

You can use the StartTime property of RadDateTimePicker and set the desired time. If you want this time to be the same for each date that can be selected, this works out of the box. If you want to apply a particular starting time only on one day, you need to implement a custom logic that checks if the day is the desired one and sets a custom value for StartTime only for this day.

You can do this in the EventHandler of the SelectionChanged event:

private void picker_SelectionChanged(object sender, SelectionChangedEventArgs e)
       {
           if ((DateTime)e.AddedItems[0] == new DateTime(2015, 07, 15, 00, 00, 00))
           {
               (sender as RadDateTimePicker).StartTime = new TimeSpan(11, 30, 00);
           }
           else
           {
               (sender as RadDateTimePicker).StartTime = new TimeSpan(00, 00, 00);
           }
       }


More on the selection in RadDateTimePicker you can find here:

http://docs.telerik.com/devtools/wpf/controls/raddatetimepicker/features/selection.html#see-also

Please note that the hours that precede the set StartTime value won't be visible.

Hope this helps.

Regards,
Geri
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
DateTimePicker
Asked by
Shoukat
Top achievements
Rank 1
Answers by
Geri
Telerik team
Share this question
or