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

TimelineItemFormatting

1 Answer 42 Views
GanttView
This is a migrated thread and some comments may be shown as answers.
kim
Top achievements
Rank 1
kim asked on 27 Nov 2018, 08:06 AM

Hi~~

 

I want use the theme and change the  backcolor of timelineitem in TimelineItemFormatting

 

protected override void OnShown(EventArgs e)

{

     ThemeResolutionService.LoadPackageFile("CustomTheme.tssp");

     ganttview.ThemeName = "CustomTheme";

     // I Use CustomTheme after not change timeline backcolor

 

}

private void ganttView_TimelineItemFormatting(object sender, GanttViewTimelineItemFormattingEvent Args e)

{

    

    

      foreach(LightVisualElement element in e.ItemElement.BottomElement.Children)

      {

          if(holidayList.Contain(element .Start))

          {

             // not chage color

             // why?

                element.BackColor = Color.Red; 

                element.BackColor2 = Color.Red;

                element.BackColor3 = Color.Red;

                element.BackColor4 = Color.Red;

           }

     }

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 28 Nov 2018, 08:53 AM
Hi Kim,

You can change the back color of the timeline cell elements in the Visual Style Builder tool, please check the attached screenshot for reference. If you want to change the back color in the TimeLineItemFormatting event, please perform the validation e.Item.Start property. The code snippet you have shared will not compile because the LightVisualElement class does not have a Start property. The event handler below is working well on my end: 
private void RadGanttView1_TimelineItemFormatting(object sender, GanttViewTimelineItemFormattingEventArgs e)
{
    foreach (LightVisualElement element in e.ItemElement.BottomElement.Children)
    {
        Console.WriteLine(e.Item.Start);
        // Validate according to the Start
 
        element.BackColor = Color.Red;
    }
}

I hope this will help.

Regards,
Hristo
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
GanttView
Asked by
kim
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or