Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
159
Hide timeslots in dayview
posted

Hi there,

Does anyone know the best way to hide timeslots in dayview?

I want to only show a calendar that starts at say 9am - 5pm instead of 12am-12am.

I have access to the source code but not sure where to start or if there is a setting somewhere else.

 

 

  • 2094
    Verified Answer
    Offline posted

    Use this Sub I wrote.

    It will scan ALL Owners DayOfWeekSettings to determine how many hours need to be displayed in the Dayview.

    Eg: If the earliest an owner begins work is 7am then it will display 1 1/2 hours before 7, making the first timeslot = 5:30am

    And if the latest any particular owner ends work it will display 1/2 an hour after that. So if latest an owner finishes is 5pm then it timeslots upto 5:30pm will be visible.

        Private Overloads Sub SetLogicalDayDuration(ByVal cinfo As UltraCalendarInfo)

            Dim LowestOpenTime As DateTime = New DateTime(2000, 1, 1, 23, 59, 59)
            Dim HighestCloseTime As DateTime = New DateTime(2000, 1, 1, 0, 0, 0)
            Dim OpenTimeResult As DateTime
            Dim CloseTimeResult As DateTime

            Try

                For Each own As Owner In cinfo.Owners
                    If own Is cinfo.Owners.UnassignedOwner Then Continue For
                    For Each DyOfWSetting As DayOfWeekSettings In own.DayOfWeekSettings
                        If DyOfWSetting.WorkDayStartTime.TimeOfDay = New TimeSpan(0, 0, 0) Then Continue For
                        If LowestOpenTime.TimeOfDay > DyOfWSetting.WorkDayStartTime.TimeOfDay Then
                            LowestOpenTime = DyOfWSetting.WorkDayStartTime
                        End If

                        If HighestCloseTime.TimeOfDay < DyOfWSetting.WorkDayEndTime.TimeOfDay Then
                            HighestCloseTime = DyOfWSetting.WorkDayEndTime
                        End If
                    Next
                Next

    'Make Sure Lowest and Highest Times are not less than or greater than midnight (00:00 hours)
                If New TimeSpan(LowestOpenTime.Hour - 1, 30, 0) < New TimeSpan(0, 0, 0) Then
                    cinfo.LogicalDayOffset = New TimeSpan(0, 0, 0)
                Else
                    cinfo.LogicalDayOffset = New TimeSpan(LowestOpenTime.Hour - 1, 30, 0)
                End If

                If New TimeSpan(HighestCloseTime.Hour - cinfo.LogicalDayOffset.TotalHours + 0, 30, 0) > New TimeSpan(24, 0, 0) Then
                    cinfo.LogicalDayDuration = New TimeSpan(23, 59, 59)
                Else
                    cinfo.LogicalDayDuration = New TimeSpan(HighestCloseTime.Hour - (cinfo.LogicalDayOffset.TotalHours - 1) + 0, 30, 0)
                End If


    'Set the CalendarInfo Properties with Result
                cinfo.LogicalDayDuration = New TimeSpan(CloseTimeResult.Hour, CloseTimeResult.Minute - 30, 0)
                cinfo.LogicalDayOffset = New TimeSpan(OpenTimeResult.Hour - 0, -30, 0)
            Catch ex As Exception
                LogPrint("Error - frmAppointments:" & ex.TargetSite.ToString & ": " & ex.Message.ToString, 5)
            End Try
        End Sub

     

    If this is all to complicated and you don't want this and you just want to statically set the time period shown then do the following:

    calInfo.LogicalDayOffset = New Timespan(9,0,0)
    calinfo.LogicalDayDuration = New Timespan(8,0,0)

    This will give you an 8 hour day starting at 9am and ending at 5pm