Unselect a selected appointment

7 posts, 0 answers
  1. Craig Gamble
    Craig Gamble avatar
    71 posts
    Member since:
    Aug 2005

    Posted 23 Apr 2009 Link to this post

    i have a little function that will loop through an active view and unselect any cells that have been selected

            private void UnselectCells()  
            {  
     
                SchedulerMonthViewElement monthView = this.schRates.SchedulerElement.ViewElement as SchedulerMonthViewElement;  
                Telerik.WinControls.RadElementCollection childrenCollection = monthView.Children[1].Children;  
     
                foreach (MonthCellElement cell in childrenCollection)  
                {  
                    if (cell.Header.Selected == true)  
                    {  
                        cell.Header.Selected = false;  
                    }  
     
                    if (childrenCollection.IndexOf(cell) == 34)  
                    { break; }  
                }  
            } 

    but i would like something similar to unselect any appointments but cant seem to find a way?? something like the following.......

            private void UnselectAppointments()  
            {  
                foreach (IEvent appointment in this.schRates.ActiveView.Appointments)  
                {  
                     
                    if (appointment.Selected == true)  
                    {  
                        appointment.Selected == false;  
                    }  
                }  
            } 

    Any help is greatly appreciated,

    Cheers,
    Craig
  2. Jordan
    Admin
    Jordan avatar
    547 posts

    Posted 24 Apr 2009 Link to this post

    Hi Craig Gamble,

    Here is a method that will unselect all selected appointments in a month view:
    private void UnselectAppointments(SchedulerMonthViewElement monthViewElement) 
            { 
                if (monthViewElement == null
                { 
                    return
                } 
                MonthViewAreaElement monthViewAreaElement = monthViewElement.Children[1] as MonthViewAreaElement; 
                if (monthViewAreaElement == null
                { 
                    return
                } 
     
                foreach (RadElement element in monthViewAreaElement.Children) 
                { 
                    AppointmentElement appointmentElement = element as AppointmentElement; 
                    if (appointmentElement != null
                    { 
                        if (appointmentElement.Selected) 
                        { 
                            appointmentElement.Selected = false
                        } 
                    } 
                } 
            } 


    This method is used like bellow:
    SchedulerMonthViewElement monthViewElement = this.radScheduler.SchedulerElement.ViewElement as SchedulerMonthViewElement; 
                this.UnselectAppointments(monthViewElement); 


    However, I have to warn you that this method will break if the element structure is changed.
    That is why we will think of an easier way to select / unselect appointments programmatically.


    Regards,
    Jordan
    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. Carlos
    Carlos avatar
    5 posts
    Member since:
    Nov 2008

    Posted 25 May 2010 Link to this post

    What about in a DayView?
  5. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 25 May 2010 Link to this post

    Hello Carlos,

    Thank for contacting us.

    You could use the following code snippet to unselect all appointments in the DayView:
     
    SchedulerDayViewElement dayViewElement = this.radScheduler1.SchedulerElement.ViewElement as SchedulerDayViewElement;
     
    DayViewAppointmentsTable dayViewAppointmentsTable = dayViewElement.Children[2].Children[0].Children[2].Children[3].Children[1] as DayViewAppointmentsTable;
    if (dayViewAppointmentsTable == null)
    {
        return;
    }
     
    foreach (RadElement element in dayViewAppointmentsTable.Children)
    {
        AppointmentElement appointmentElement = element as AppointmentElement;
        if (appointmentElement != null)
        {
            if (appointmentElement.Selected)
            {
                appointmentElement.Selected = false;
            }
        }
    }

    Do not hesitate to contact us for further questions.

    All the best,
    Dobry Zranchev
    the Telerik team

    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 Public Issue Tracking system and vote to affect the priority of the items.
  6. Carlos
    Carlos avatar
    5 posts
    Member since:
    Nov 2008

    Posted 27 May 2010 Link to this post

    Thank you very much Dobry.
  7. Pramod
    Pramod avatar
    8 posts
    Member since:
    Dec 2015

    Posted 28 Jun in reply to Dobry Zranchev Link to this post

    Hi Telerik Team,

    I am using different view of Scheduler control, like DayView, WeekView/WorkWeekView and GroupedByResourceView etc...
    What could be the best solutiuon to unselect the selected appointment?
    Please help me to find best way.

    Note : Am using the Telerik Version : 2014.2.617.0

    Thanks
    Pramod
  8. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 28 Jun Link to this post

    Hello Pramod,

    Thank you for writing. 

    We introduced an improved RadScheduler in Q2 2014 (version 2014.2.617). Now, it provides SchedulerSelectionBehavior which performs selection operations and provides information about the current selection of cells and appointments in RadScheduler. You can use the public API for unselecting a specific appointment. Additional information is available here: http://docs.telerik.com/devtools/winforms/scheduler/fundamentals/scheduler-selection

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

    Regards,
    Dess
    Telerik
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
Back to Top
UI for WinForms is Visual Studio 2017 Ready