Child band color (alternating row colors parent band)

Hi,

I have a data band with a nested data band. The parent band has an EvenStyle set. I want to color the child data bands in the same color as the parent but everything I try fails.

Anyone done this before?

Regards, Tim

Comments

  • Hello!

    To color the cells/text of a child band to match the color of the current parent row, use the BeforePrint method (or the Highlight condition) while tracking whether the parent row is even-indexed:

    private int parentIdx = 0;
    private void ParentBand_BeforePrint(object sender, EventArgs e)
    {
    parentIdx++;
    }
    
    private void ChildBand_BeforePrint(object sender, EventArgs e)
    {
    var color = (parentIdx % 2 == 0) ? Color.Silver : Color.Transparent;
    ChildBand.Fill = new SolidFill(color);
    }
    

    (Alternatively, in the Highlight condition for child objects, specify the expression ParentBand.RowNo % 2 == 0.)

This discussion has been closed.