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

Border for selected items

1 Answer 70 Views
GanttView
This is a migrated thread and some comments may be shown as answers.
Sebastiaan
Top achievements
Rank 1
Sebastiaan asked on 16 Aug 2017, 01:39 PM

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?

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 17 Aug 2017, 07:41 AM
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.
Tags
GanttView
Asked by
Sebastiaan
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or