Change appointment element height

5 posts, 0 answers
  1. Karl
    Karl avatar
    172 posts
    Member since:
    Sep 2010

    Posted 24 Jul 2012 Link to this post

    Is it possible to change the height of appointments in the schedulers timeline view?

    Either a fixed size or a "fill" option - where the appointment would fill the day/resource cell- would be great. In the case of the fill option, multiple appointments would divide available space between them until such time as the text becomes unreadable, then they scroll.

    If either of these options are possible, can someone please point me in the right direction so I can implement it on my control?

  2. Ivan Todorov
    Ivan Todorov avatar
    688 posts

    Posted 25 Jul 2012 Link to this post

    Hello Karl,

    Thank you for your question.

    There is an AppointmentHeight property in the SchedulerTimelineViewElement which you can use to set fixed height for all appointments. You can set this property in the VisualStyleBuilder as it is demonstrated on the attached screenshot. In case you want to dynamically calculate the value of this property, you can also set it via the following code:
    SchedulerTimelineViewElement timeline = this.radScheduler1.SchedulerElement.ViewElement as SchedulerTimelineViewElement;
    if (timeline != null)
        timeline.AppointmentHeight = value;

    I hope you find this useful. Feel free to ask if you have any additional questions.

    Kind regards,
    Ivan Todorov
    the Telerik team
    RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
  3. David
    David avatar
    6 posts
    Member since:
    Oct 2015

    Posted 17 Nov 2015 in reply to Ivan Todorov Link to this post

    Is there a way to set the AppointmentHeight in GroupedByResource mode when in TimeLineView ?

    Because when using the code above, SchedulerTimelineViewElement returns null.

    Here's the code I'm using :


    01.For i = 0 To pDataSetRessources.Count - 1
    02.   Dim lMachine As New Resource()
    03.   lMachine.Id = New EventId(pDataSetRessources.Item(i).Id)
    04.   lMachine.Name = pDataSetRessources.Item(i).Nom
    05.   lMachine.Color = If(i Mod 2 = 0, Color.White, Color.Gray)
    07.   Me.RadScheduler_PlanningOf.Resources.Add(lMachine)
    10.RadScheduler_PlanningOf.GroupType = GroupType.Resource
    14.Me.RadScheduler_PlanningOf.ActiveViewType = SchedulerViewType.Timeline
    17.           Dim timelineViewElement As SchedulerTimelineViewElement = _
    18.              TryCast(Me.RadScheduler_PlanningOf.SchedulerElement.ViewElement, _
    19.                  SchedulerTimelineViewElement)
    21.           If Not IsNothing(timelineViewElement) Then ' Returns nothing :'(
    22.               'No Way
    23.               timelineViewElement.AppointmentHeight = 200
    24.               'If Only ...
    25.               timelineViewElement.Presenter.AppointmentHeight = 200
    26.           End If



    P.S. I've seen there's classes dedicated to GroupedByResource that might help like
    SchedulerDayViewGroupedByResourceElement > SchedulerDayViewElement
    But no such class for TimeLineView

  4. Dess
    Dess avatar
    1711 posts

    Posted 20 Nov 2015 Link to this post

    Hello David,

    Thank you for writing.

    Here is a sample code snippet demonstrating how to specify the AppointmentHeight property for each SchedulerTimelineViewElement associated with a resource: 
    Sub New()
        Dim colors() As Color = {Color.LightBlue, Color.LightGreen, Color.LightYellow, Color.Red, Color.Orange}
        Dim names() As String = {"Alan Smith", "Anne Dodsworth", "Boyan Mastoni", "Richard Duncan", "Maria Shnaider"}
        For i As Integer = 0 To names.Length - 1
            Dim resource As New Telerik.WinControls.UI.Resource()
            resource.Id = New EventId(i)
            resource.Name = names(i)
            resource.Color = colors(i)
        Next i
        Me.RadScheduler1.GroupType = GroupType.Resource
        Me.RadScheduler1.ActiveView.ResourcesPerView = Me.RadScheduler1.Resources.Count
        Me.RadScheduler1.ActiveViewType = SchedulerViewType.Timeline
        Dim rand As New Random
        For index = 1 To 10
            Dim a As New Appointment(DateTime.Now.AddHours(index), TimeSpan.FromHours(2), "A" & index)
            a.ResourceId = Me.RadScheduler1.Resources(rand.Next(0, Me.RadScheduler1.Resources.Count)).Id
        Dim timelineElement As TimelineGroupingByResourcesElement = TryCast(Me.RadScheduler1.SchedulerElement.ViewElement, TimelineGroupingByResourcesElement)
        For Each el As RadElement In timelineElement.Children
            Dim t As SchedulerTimelineViewElement = TryCast(el, SchedulerTimelineViewElement)
            If t IsNot Nothing Then
                t.AppointmentHeight = 50
            End If
    End Sub

    I hope this information helps. Should you have further questions I would be glad to help.
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  5. David
    David avatar
    6 posts
    Member since:
    Oct 2015

    Posted 24 Nov 2015 in reply to Dess Link to this post

    It works perfectly, thanks a lot.
Back to Top