How to get selected time period

10 posts, 1 answers
  1. Marcus
    Marcus avatar
    5 posts
    Member since:
    Jun 2009

    Posted 08 Jun 2009 Link to this post

    I have a RadScheduler that I've set up to drag and drop different tasks from a list box. Currently the task only fills one time slot (which is set at half-hour intervals) however I would like the user to be able to select a time period and drag the task to the selected area and have the "appointment" fill the entire selected area. 

    I am having trouble retrieving the selected time period from the WinForms scheduler, is there a way to get the selected TimeSlot?

    Thanks is advance,
  2. Answer
    Boyko Markov
    Boyko Markov avatar
    610 posts

    Posted 11 Jun 2009 Link to this post

    Hello Marcus,

    Thank you for contacting us. I have prepared a simple solution how to get the selection start and selection end dates.

    1. Get the dayview element instance from RadScheduler.

      SchedulerDayViewElement dayview = (this.radSchedulerDemo.SchedulerElement.ViewElement as SchedulerDayViewElement);
    2. Get the selection MinDate and selection MaxDate. I'm doing this by iterating over the cells collection. Then check whether a cell is selected and initialize the minDate and maxDate fields:

                DateTime minDate = DateTime.MaxValue;
                DateTime maxDate = DateTime.MinValue;

                foreach (RadElement element in dayview.DataAreaElement.Table.Children)
                    SchedulerCellElement cell = element as SchedulerCellElement;
                    if (cell != null && cell.Selected)
                        if (minDate >= cell.Date)
                            minDate = cell.Date;

                        if (maxDate <= cell.Date)
                            maxDate = cell.Date;

                TimeSpan selectionDuration = maxDate - minDate;

    I hope this helps. Do not hesitate to write me back if you have further questions.

    Kind regards,
    Boyko Markov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Marcus
    Marcus avatar
    5 posts
    Member since:
    Jun 2009

    Posted 12 Jun 2009 Link to this post

    Thanks! That almost got it, I just had to add time to the end of the max date (thirty minutes in my case) to find the time period from the beginning of the first cell to the end of the last cell.

    Thanks for the help.
  4. luca
    luca avatar
    9 posts
    Member since:
    Feb 2008

    Posted 02 Oct 2009 Link to this post

    I had the same request and thank to that explanation i resolved! Thanks Boyko Markov for the perfect solution
  5. Denis Cilliers
    Denis Cilliers avatar
    62 posts
    Member since:
    Jan 2004

    Posted 02 Oct 2012 Link to this post

    How would this be applied in VB.Net as the line 
    dayview = TryCast(Me.radSchedulerDemo.SchedulerElement.ViewElement, SchedulerDayViewElement)

    does not return anything for a selection event
  6. Ivan Todorov
    Ivan Todorov avatar
    688 posts

    Posted 10 Oct 2012 Link to this post

    Hi Denis,

    This is the correct way to get the SchedulerDayViewElement, however you can get it only if RadScheduler is currently under DayView. Otherwise the ViewElement will be of different type and the TryCast will return Nothing.

    If your goal is to get the selected dates, then you can use the following method to achieve this without having to cast any elements:
    Dim dates As DateTime() = SchedulerUIHelper.GetSelectedDates(Me.RadScheduler1)
    Dim interval As New DateTimeInterval(dates(0), dates(dates.Length - 1))

    If your requirement is different, then please share more details on it and I will assist you in achieving it.

    Should you have any other questions, feel free to ask.

    Kind regards,
    Ivan Todorov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  7. Gerhard
    Gerhard avatar
    4 posts
    Member since:
    Jan 2012

    Posted 03 Dec 2012 Link to this post

    How do I do this in It loops through the 72 cells but everyone seems is selected = false.
  8. Ivan Todorov
    Ivan Todorov avatar
    688 posts

    Posted 06 Dec 2012 Link to this post

    Hello Gerhard,

    The approach should be the same in C# and VB. However, you can try using one of the following methods of the SchedulerUIHelper class:

    If you have any additional questions, please let me know.

    Ivan Todorov
    the Telerik team
    Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
  9. Chandz
    Chandz avatar
    7 posts
    Member since:
    Feb 2016

    Posted 03 Feb 2016 Link to this post

    Hello Telerik team,

     I have a Radscheduler and an individual button, in a web form in my aspx page(c# and

    when in week view of the scheduler, it displays the first week (i.e)  jan 3 2016 sunday to jan 9 2016 saturday,

    i want to view the next week on button click (i.e)  jan 10 2016 sunday to jan 16 2016 saturday,

    telerik has dayview, weekview, monthview, agendaview and timelineview but not nextweekview..

    Googling does not help me in this case.


    Thanks in advance..

    Hope you people reply a bit faster.
  10. Dess
    Dess avatar
    2107 posts

    Posted 03 Feb 2016 Link to this post

    Hello Chandz,

    Thank you for writing.

    I would like to note that this forum is related to the Telerik UI for WinForms suite. However, your question seems to be connected with the ASP.NET product. Feel free to post your question in the relevant forum:

    I hope this information helps. Should you have further questions I would be glad to help.

    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
Back to Top