Hierarchical Grid Alternate color

3 posts, 1 answers
  1. pierre-jean
    pierre-jean avatar
    136 posts
    Member since:
    Apr 2011

    Posted 28 Jan 2013 Link to this post

    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. Answer
    Stefan
    Admin
    Stefan avatar
    2911 posts

    Posted 31 Jan 2013 Link to this post

    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.
  3. pierre-jean
    pierre-jean avatar
    136 posts
    Member since:
    Apr 2011

    Posted 31 Jan 2013 Link to this post

    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
Back to Top