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

Hierarchical Grid Alternate color

2 Answers 122 Views
GridView
This is a migrated thread and some comments may be shown as answers.
pierre-jean
Top achievements
Rank 1
Veteran
Iron
pierre-jean asked on 28 Jan 2013, 03:11 PM
Hello
I have a grid with alternate colors that I set as follows
                    gvRiders.TableElement.BackColor = My.Settings.lvColor1
                    gvRiders.TableElement.AlternatingRowColor = My.Settings.lvColor2
The colors are correct on the "main" grid, but They are not propagated to the sub-grids (I have two levels of hierarchy in the grid),The sub-grids are displaying alternate colors, but not the same as the main grid, it seems to be teh default colors.
How do I set the backcolor and alternaterowcolor of the sub-grids ?

thanks in advance

2 Answers, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 31 Jan 2013, 09:34 AM
Hello Pierre-Jean,

Thank you for writing.

The color of the TableElement you have specified will be applied only to the MasterTemplate's TableElement. In order to apply the same color to the rest of the templates, you should use the following code in your CellFormatting event handler:
void radGridView1_CellFormatting(object sender, CellFormattingEventArgs e)
{
    if (e.CellElement.ViewTemplate != radGridView1.MasterTemplate)
    {
        e.CellElement.TableElement.AlternatingRowColor = radGridView1.TableElement.AlternatingRowColor;
    }
}

I hope this helps.

Regards,
Stefan
the Telerik team
Q3'12 SP1 of RadControls for WinForms is out now. See what's new.
0
pierre-jean
Top achievements
Rank 1
Veteran
Iron
answered on 31 Jan 2013, 10:28 AM
Thanks a lot
it works perfectly, I just added the backcolor so that the "normal" row and the alternate row have the same color as the Mastertemplates
thanks again
Tags
GridView
Asked by
pierre-jean
Top achievements
Rank 1
Veteran
Iron
Answers by
Stefan
Telerik team
pierre-jean
Top achievements
Rank 1
Veteran
Iron
Share this question
or