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

ScrollControlIntoView (AppointmentElement)

5 Answers 205 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Raoul
Top achievements
Rank 1
Raoul asked on 13 Apr 2012, 08:56 PM
How can I scroll a appointment into view?

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 Sub

When 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

Sort by
0
Accepted
Ivan Todorov
Telerik team
answered on 18 Apr 2012, 02:47 PM
Hi Raoul,

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
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
Raoul
Top achievements
Rank 1
answered on 21 Apr 2012, 08:44 PM
Ivan,
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
0
Ivan Todorov
Telerik team
answered on 23 Apr 2012, 03:21 PM
Hello 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
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
Victor
Top achievements
Rank 2
answered on 26 Nov 2018, 10:23 PM

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();
        }

 

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 27 Nov 2018, 02:58 PM
Hello, Victor,  

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
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Scheduler and Reminder
Asked by
Raoul
Top achievements
Rank 1
Answers by
Ivan Todorov
Telerik team
Raoul
Top achievements
Rank 1
Victor
Top achievements
Rank 2
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or