Alternating background color in a Matrix

  • I tried

    = iif (RowNumber (nothing) Mod 2, "Lightgrey", "transparent")

     

    but the resulto was weird. It was not alternating correctly.

    In the columns group i could not use

    = iif (RowNumber (nothing) Mod 2, "Lightgrey", "transparent")

    this error occurred

    The background color expression for the textbox ‘delta_odometro’ has a scope parameter that is not valid for RunningValue, RowNumber or Previous. The scope parameter must be set to a string constant that is equal to the name of a containing group within the matrix ‘matrix1’.

    Build complete -- 1 errors, 0 warnings

    Someone could help?

  • I'm probably out of my depth here.....but as in crystal reports is there not a function that will allow you to do this depending on the remainder left when you divide the row number by 2

    if Rem(row Number/2)>0 then LightGrey Else Transparent

    This is NOT the correct syntax, but I was just reading this over lunch...........

  • Try this:

    =IIf(RowNumber("table2") Mod 2, "White","Gainsboro")

  • Luiz,

    RowNumber function doesn't work with matrices because it returns row number in dataset, not in matrix.

    Here's what I did to alternate colors in matrix rows.

    1. I've created a function

      Public BackColor As String = "White"

      Public Function GetBackColor() As String

       If BackColor = "White" Then

        BackColor = "Gainsboro"

       Else

        BackColor = "White"

       End If

       Return BackColor

      End Function

    2. In the column header BackgroundColor Property I put the following expression:

      =Code.GetBackColor()

    3. In the matrix cell BackgroundColor Property I put the following expression:

      =Code.BackColor

    It worked for me. Try it

  • Thanks Grasshopper,

    Worked fine. Helped a lot.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply