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

ScrollToWorkHours not working

1 Answer 93 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 12 Jul 2011, 05:31 AM
 Hi,

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()
            Else
                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.

Regards.

1 Answer, 1 is accepted

Sort by
0
Accepted
Ivan Todorov
Telerik team
answered on 14 Jul 2011, 03:25 PM
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:
Me.radScheduler1.SchedulerElement.ViewElement.InvalidateMeasure(True)
Me.radScheduler1.SchedulerElement.ViewElement.UpdateLayout()

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!

Tags
Scheduler and Reminder
Asked by
Richard
Top achievements
Rank 1
Answers by
Ivan Todorov
Telerik team
Share this question
or