I can set focus to it, but when it's not in view, i can't seem to scroll to it. This is my code:
Private Sub FocusAppointment(afspraak As Agenda) Dim app As Appointment = RadScheduler1.Appointments.FirstOrDefault(Function(c) c.UniqueId.KeyValue.Equals(afspraak.AgendaID)) If app IsNot Nothing Then For Each appElement As AppointmentElement In SchedulerUIHelper.GetAppointmentElements(RadScheduler1) Dim evnt As IEvent = appElement.Appointment If evnt.UniqueId.KeyValue = afspraak.AgendaID Then RadScheduler1.FocusedElement = appElement RadScheduler1.ScrollControlIntoView(appElement) '<- Telerik.WinControls.UI.AppointmentElement' cannot be converted to 'System.Windows.Forms.Control End If Next End If End SubWhen commenting the 'scrollintoview-line' the code works and the selected appointment does get focus, but out of view...
I obviously overlook something here.
Kind Regards,
Raoul
5 Answers, 1 is accepted
Thank you for writing.
The ScrollControlIntoView method comes from the base implementation of the ScrollableControl in .NET Framework and it works only with nested controls. However, the structure of our controls consists of visual elements called RadElements that are not actually controls.
As to your current requirement, you can use the BringAppointmentIntoView method of the static SchedulerUIHelper class to achieve the desired functionality:
SchedulerUIHelper.BringAppointmentIntoView(appElement.Appointment, RadScheduler1) ' instead of RadScheduler1.ScrollControlIntoView(appElement)I hope this will help you. Do not hesitate to ask if you have any further questions.
All the best,
Ivan Todorov
the Telerik team
Thanks for your reply. Turned out this method is not available in 2011Q2. I'm doing maintenance on software for a new client which uses the 2011Q2 winforms controls. Anyway, turns out RadScheduler.GetChildAtPoint returns a control :)
RadScheduler1.ScrollControlIntoView(RadScheduler1.GetChildAtPoint(appElement.Location))Regards,
Raoul
Indeed, the BringAppointmentIntoView method is not available in Q2 2011. I am posting here the code of this method so you can use it with the Q2 2011 version:
public static void BringAppointmentIntoView(IEvent appointment, RadScheduler scheduler){ scheduler.ActiveView.StartDate = appointment.Start.AddDays(-1); int resIndex = scheduler.Resources.IndexOf(scheduler.Resources.GetById(appointment.ResourceId)); SchedulerDayViewGroupedByResourceElement dayViewGrouped = scheduler.SchedulerElement.ViewElement as SchedulerDayViewGroupedByResourceElement; SchedulerMonthViewGroupedByResourceElement monthViewGrouped = scheduler.SchedulerElement.ViewElement as SchedulerMonthViewGroupedByResourceElement; TimelineGroupingByResourcesElement timelineGrouped = scheduler.SchedulerElement.ViewElement as TimelineGroupingByResourcesElement; if (dayViewGrouped != null) { dayViewGrouped.NavigateToResource(resIndex); foreach (SchedulerDayViewElement dvElement in dayViewGrouped.GetDayViewElements()) { dvElement.DataAreaElement.Table.ScrollToTime(TimeSpan.FromHours(appointment.Start.Hour)); } } if (monthViewGrouped != null) { monthViewGrouped.NavigateToResource(resIndex); } if (timelineGrouped != null) { timelineGrouped.NavigateToResource(resIndex); } SchedulerDayViewElement dayViewElement = scheduler.SchedulerElement.ViewElement as SchedulerDayViewElement; if (dayViewElement != null) { dayViewElement.DataAreaElement.Table.ScrollToTime(TimeSpan.FromHours(appointment.Start.Hour)); }}I hope this will help you. If you have any additional questions, feel free to ask.
All the best,
Ivan Todorov
the Telerik team
Hi,
In a Scheduler in Timeline view with a bespoke Elementprovider and AppointmentElement I use the method :
SchedulerUIHelper.BringAppointmentIntoView(appElement.Appointment, RadScheduler1)
It works, but is there a quicker way to put an appointment on-screen? If I have a scheduler with approx 600 appointments it takes about 1.5 seconds to for the appointment get into view. Hope you can help.
The code
public void gotoAppointment(string cost_code)
{
timeLineRitten.SuspendUpdate();
timeLineRitten.SuspendLayout();
timeLineRitten.Appointments.BeginUpdate();
m_bIsLoading = true;
try
{
for (int i = 0; i < timeLineRitten.Appointments.Count; i++)
{
if (timeLineRitten.Appointments[i].Description == cost_code.Trim())
{
AppointmentRit app2 = (AppointmentRit)timeLineRitten.Appointments[i];
IEvent app = timeLineRitten.Appointments[i];
SchedulerUIHelper.BringAppointmentIntoView(app, timeLineRitten,true);
timeLineRitten.SelectionBehavior.SelectAppointment(app2, true);
break;
}
}
}
catch (Exception e)
{
new Error(e);
}
m_bIsLoading = false;
timeLineRitten.Appointments.EndUpdate();
timeLineRitten.ResumeLayout();
timeLineRitten.ResumeUpdate();
}
The SchedulerUIHelper.BringAppointmentIntoView method is an appropriate solution for scrolling the view to the desired appointment. Following the provided information, I was unable to reproduce the issue you are facing. RadScheduler scrolls instantly to the desired appointment. I have attached my sample project. Could you please specify the exact steps how to reproduce the problem so I can investigate the precise case. Thank you in advance.
I am looking forward to your reply.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
