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

Change Parent Row BorderColor when Child Rows are expanded

2 Answers 72 Views
GridView
This is a migrated thread and some comments may be shown as answers.
christian
Top achievements
Rank 1
christian asked on 06 Nov 2015, 03:37 PM

Hi Telerik,

 I use the RowFormatting Event to change the bordel color of the parentrow when childrows are expanded, here's my code :

 

private void GridEmployeRenard_RowFormatting(object sender, Telerik.WinControls.UI.RowFormattingEventArgs e)
       {
           if (e.RowElement.RowInfo.IsExpanded)
           {
               e.RowElement.BorderColor = RowExpandedColor; // RowExpandedColor is set above in the code
           }
           else
           {
               e.RowElement.ResetValue(Telerik.WinControls.UI.LightVisualElement.BorderColorProperty, ValueResetFlags.Local);
           }
       }

However when the row losts focus, the bordercolor is reset.
I need the rowBorderColor keeps the RowExpandedColor value until the row is collapsed by the user.

Any idea to do that please ?

 

Regards.

2 Answers, 1 is accepted

Sort by
0
Accepted
Dess | Tech Support Engineer, Principal
Telerik team
answered on 11 Nov 2015, 08:57 AM
Hello Christian,

Thank you for writing.

I am not sure whether you use the ControlDeafult but note that by default cell elements have applied border as well. In order to apply a row border, it is necessary to hide the cell border. Here is a sample code snippet which result is illustrated on the attached screenshot:
private void radGridView1_RowFormatting(object sender, Telerik.WinControls.UI.RowFormattingEventArgs e)
{
    if (e.RowElement.RowInfo.IsExpanded)
    {
        e.RowElement.DrawBorder = true;
        e.RowElement.BorderColor = Color.Red;
        e.RowElement.BorderGradientStyle = GradientStyles.Solid;
        e.RowElement.BorderWidth = 2;
    }
    else
    {
        e.RowElement.ResetValue(Telerik.WinControls.UI.LightVisualElement.DrawBorderProperty, ValueResetFlags.Local);
        e.RowElement.ResetValue(Telerik.WinControls.UI.LightVisualElement.BorderColorProperty, ValueResetFlags.Local);
        e.RowElement.ResetValue(Telerik.WinControls.UI.LightVisualElement.BorderGradientStyleProperty, ValueResetFlags.Local);
        e.RowElement.ResetValue(Telerik.WinControls.UI.LightVisualElement.BorderWidthProperty, ValueResetFlags.Local);
    }
}
 
private void radGridView1_CellFormatting(object sender, Telerik.WinControls.UI.CellFormattingEventArgs e)
{
    if (e.Row.IsExpanded)
    {
        e.CellElement.DrawBorder = false;
    }
    else
    {
        e.CellElement.ResetValue(Telerik.WinControls.UI.LightVisualElement.DrawBorderProperty, ValueResetFlags.Local);
    }
 
    if (e.CellElement.IsCurrent)
    {
        e.CellElement.DrawFill = false;
    }
    else
    {
        e.CellElement.ResetValue(Telerik.WinControls.UI.LightVisualElement.DrawFillProperty, ValueResetFlags.Local);
    }
}

I hope this information helps. Should you have further questions I would be glad to help.
 
Regards,
Dess
Telerik
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
0
christian
Top achievements
Rank 1
answered on 12 Nov 2015, 09:42 AM

Thanks Dess.

Your example works fine.

Tags
GridView
Asked by
christian
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
christian
Top achievements
Rank 1
Share this question
or