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

Find appointment details while looping through MonthView

2 Answers 92 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Craig Gamble
Top achievements
Rank 1
Craig Gamble asked on 21 Apr 2009, 09:11 AM
i currently loop through a month view to find out if certain cells have been selected

            SchedulerMonthViewElement monthView = this.schRates.SchedulerElement.ViewElement as SchedulerMonthViewElement;  
            Telerik.WinControls.RadElementCollection childrenCollection = monthView.Children[1].Children;  
 
 
            DateTime startDate = DateTime.MinValue;  
            DateTime endDate = DateTime.MinValue;    
 
 
            foreach (MonthCellElement cell in childrenCollection)  
            {  
                if (cell.Header.Selected == true)  
                {  
                    if (startDate == DateTime.MinValue)  
                    {  
                        startDate = cell.Date;  
                    }  
                    else  
                    {  
                        endDate = cell.Date;  
                    }  
                }  
 
                if (childrenCollection.IndexOf(cell) == 34)  
                { break; }  
            } 

i need to expand upon this, and check if any appointments already exist on a selected cell but cant seem to find any property or method within the cell item that will allow me to check this.

any help is greatly appreciated.

Cheers,
Craig

2 Answers, 1 is accepted

Sort by
0
Accepted
Jordan
Telerik team
answered on 21 Apr 2009, 02:16 PM
Hello Craig Gamble,

It will be easy to get the appointments that intersect with the selected interval by using the IntersectsWith method of the DateTimeInterval class like bellow:

DateTime start = DateTime.Today.AddHours(12.0); 
            DateTimeInterval selectedInterval = new DateTimeInterval(start, start.AddHours(6.0)); 
            List<IEvent> selectedAppointments = new List<IEvent>(); 
 
            foreach (IEvent appointment in this.radScheduler1.ActiveView.Appointments) 
            { 
                DateTimeInterval appointmentInterval = new DateTimeInterval(appointment.Start, appointment.End); 
                if (selectedInterval.IntersectsWith(appointmentInterval)) 
                { 
                    selectedAppointments.Add(appointment); 
                } 
            } 

I hope this helps.

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.
0
Craig Gamble
Top achievements
Rank 1
answered on 21 Apr 2009, 03:37 PM
Good stuff

Cheers,
Craig
Tags
Scheduler and Reminder
Asked by
Craig Gamble
Top achievements
Rank 1
Answers by
Jordan
Telerik team
Craig Gamble
Top achievements
Rank 1
Share this question
or