ScrollToWorkHours not working

2 posts, 1 answers
  1. Richard
    Richard avatar
    32 posts
    Member since:
    Aug 2010

    Posted 12 Jul 2011 Link to this post


    I have got a scheduler control, which scrolls to work hours perfectly well when the view is changed (Day, Week). However, when the "ShowWeekend" check box is toggled, the scroll to work time does not work.

    The code:
    Private Sub radSchedulerAppointmentsNavigator_ShowWeekendStateChanged(ByVal sender As Object, ByVal args As Telerik.WinControls.UI.StateChangedEventArgs) Handles radSchedulerAppointmentsNavigator.ShowWeekendStateChanged
    If TryCast(Me.radSchedulerAppointments.ActiveView, SchedulerMonthView) Is Nothing Then
                TryCast(Me.radSchedulerAppointments.ActiveView, SchedulerDayViewBase).RulerWidth = 43
                TryCast(Me.radSchedulerAppointments.ActiveView, SchedulerDayViewBase).DayCount = 1
                TryCast(Me.radSchedulerAppointments.ActiveView, SchedulerDayViewBase).AutoScrollToWorkTime = True
                Dim dtStart As DateTime = DateTime.Parse(GetOptionValue("WORKINGHOURS", "Start"))
                Dim tsStart As New TimeSpan(dtStart.Hour, dtStart.Minute, 0)
                Dim dtEnd As DateTime = DateTime.Parse(GetOptionValue("WORKINGHOURS", "End"))
                Dim tsEnd As New TimeSpan(dtEnd.Hour, dtStart.Minute, 0)
                TryCast(Me.radSchedulerAppointments.ActiveView, SchedulerDayViewBase).WorkTime = New TimeInterval(tsStart, tsEnd)
                If RadRadioButtonGroup.ToggleState = Enumerations.ToggleState.On Then
                    TryCast(Me.radSchedulerAppointments.SchedulerElement.ViewElement, SchedulerDayViewGroupedByResourceElement).ScrollToWorkHours()
                    TryCast(Me.radSchedulerAppointments.ActiveView, SchedulerDayViewBase).RulerWidth = 45
                    TryCast(Me.radSchedulerAppointments.SchedulerElement.ViewElement, SchedulerDayViewElement).DataAreaElement.ScrollView.Value = Point.Empty
                    TryCast(Me.radSchedulerAppointments.SchedulerElement.ViewElement, SchedulerDayViewElement).DataAreaElement.Table.ScrollToWorkHours()
                End If
            End If
        End Sub

    Interestingly, if the scheduler is "Grouped by resources" mode (determined by RadRadioButtonGroup.ToggleState), then the scrolling works as required. If it is in normal mode (where RadRadioButtonGroup.ToggleState <> ToggleState.On), scrolling does not work, and the scheduler view starts at 2 AM. Working hours are being determined by options - and the work time is being specified correctly from options (8 AM to 5 PM).

    BTW, what does "AutoScrollToWorkTime" do? I did not have it before, but it doesn't seem to make any difference.

    Similar code is being used in ActiveViewChanged event of the scheduler control.

    Also, I am working with Telerik WinForms version Q1 2011 (and VS 2010). As far as I remember, the code worked before the controls were upgraded from version Q2 2010 SP1. But I could be wrong.

  2. Answer
    Ivan Todorov
    Ivan Todorov avatar
    688 posts

    Posted 14 Jul 2011 Link to this post

    Hello Richard,

    The problems with the scrolling when you change the 'Show Weekend' checkbox is present, because you are trying to scroll the view when it has not yet identified its size. To fix this, you just need to call the following lines of code before you try to scroll to the working time:

    As to your second question, the AutoScrollToWorkTime property enables automatic scrolling to work time in some occasions, for example when a view is refreshed.

    Hope this helps. Feel free to ask if you have any additional questions.

    Best wishes,
    Ivan Todorov
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

  3. DevCraft banner
Back to Top