Border for selected items

2 posts, 0 answers
  1. Sebastiaan
    Sebastiaan avatar
    1 posts
    Member since:
    Jul 2017

    Posted 16 Aug Link to this post

    Hi,

    I have an eventhandler for the GraphicalViewItemFormatting event so I can change the look&feel of the items in the ganttview according to the contents. Now I also want to make it more clear which item is selected. Unfortunately I seem to be doing something wrong. 

     

    In the handler I have this part that should draw the border in red:

    private void GanttViewElement_GraphicalViewItemFormatting(object sender, Telerik.WinControls.UI.GanttViewGraphicalViewItemFormattingEventArgs e)
    {

    if (e.ItemElement.Selected)
                {                
                    e.ItemElement.TaskElement.BorderColor = Color.Red;
                    e.ItemElement.TaskElement.BorderBoxStyle = Telerik.WinControls.BorderBoxStyle.FourBorders;
                    e.ItemElement.TaskElement.BorderWidth = 6;
                    e.ItemElement.TaskElement.BorderDashStyle = System.Drawing.Drawing2D.DashStyle.Solid;
                    e.ItemElement.TaskElement.DrawBorder = true;
                    
                }

    }

     

    But the border keeps working in the standard way. There is only a slight difference between selected and non-selected items.

    What part am I missing?

  2. Dess
    Admin
    Dess avatar
    2101 posts

    Posted 17 Aug Link to this post

    Hello Sebastiaan, 

    Thank you for writing.  

    The BorderColor property is applicable when the BorderBoxStyle property is set to SingleBorder. In the case of BorderBoxStyle.FourBorders, you should specify the BorderTopColor, BorderRightColor, BorderLeftColor, BorderBottomColor properties:
    private void radGanttView1_GraphicalViewItemFormatting(object sender, GanttViewGraphicalViewItemFormattingEventArgs e)
    {
        if (e.ItemElement.Selected)
        {
            e.ItemElement.TaskElement.BorderBottomColor = Color.Red;
            e.ItemElement.TaskElement.BorderTopColor = Color.Red;
            e.ItemElement.TaskElement.BorderRightColor = Color.Red;
            e.ItemElement.TaskElement.BorderLeftColor = Color.Red;
            e.ItemElement.TaskElement.BorderBoxStyle = Telerik.WinControls.BorderBoxStyle.FourBorders; 
            e.ItemElement.TaskElement.DrawBorder = true;
        }
        else
        {
            e.ItemElement.TaskElement.ResetValue(LightVisualElement.BorderBottomColorProperty, Telerik.WinControls.ValueResetFlags.Local);
            e.ItemElement.TaskElement.ResetValue(LightVisualElement.BorderTopColorProperty, Telerik.WinControls.ValueResetFlags.Local);
            e.ItemElement.TaskElement.ResetValue(LightVisualElement.BorderRightColorProperty, Telerik.WinControls.ValueResetFlags.Local);
            e.ItemElement.TaskElement.ResetValue(LightVisualElement.BorderLeftColorProperty, Telerik.WinControls.ValueResetFlags.Local);
            e.ItemElement.TaskElement.ResetValue(LightVisualElement.BorderBoxStyleProperty, Telerik.WinControls.ValueResetFlags.Local);
            e.ItemElement.TaskElement.ResetValue(LightVisualElement.DrawBorderProperty, Telerik.WinControls.ValueResetFlags.Local);
        }
    }

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Progress Telerik
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top