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

    Hi,
    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,
    Marcus
  2. Answer
    Boyko Markov
    Admin
    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. UI for WinForms is Visual Studio 2017 Ready
  4. 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.
  5. 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
  6. Denis Cilliers
    Denis Cilliers avatar
    62 posts
    Member since:
    Jan 2004

    Posted 02 Oct 2012 Link to this post

    Hi 
    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
  7. Ivan Todorov
    Admin
    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)
    Array.Sort(dates)
    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.
  8. Gerhard
    Gerhard avatar
    4 posts
    Member since:
    Jan 2012

    Posted 03 Dec 2012 Link to this post

    How do I do this in VB.net. It loops through the 72 cells but everyone seems is selected = false.
  9. Ivan Todorov
    Admin
    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:
    SchedulerUIHelper.GetCells(Me.RadScheduler1)
    SchedulerUIHelper.GetSelectedCells(Me.RadScheduler1)
    SchedulerUIHelper.GetSelectedDates(Me.RadScheduler1)

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

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

    Posted 03 Feb 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 Asp.net).

    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.
  11. Dess
    Admin
    Dess avatar
    1605 posts

    Posted 03 Feb 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: http://www.telerik.com/forums

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

    Regards,
    Dess
    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
Back to Top
UI for WinForms is Visual Studio 2017 Ready