Conditional formatting on a column

Posted by: j2associates on 8 September 2017, 2:02 pm EST

  • Posted 8 September 2017, 2:02 pm EST

    Hello all,


    I have a column with a checkbox celltype which is working fine. I need to set the background color for cells that are NOT checked. How do I set conditional formatting with a background color for the entire column. I don't want to have to spin through each row setting if for each cell in the column. Thanks in advance for any ideas and/or suggestions!

  • Replied 8 September 2017, 2:02 pm EST

    Hello,

    On the basis of Cell's Value you can get to know whether a Cell is Checked or not, and after knowing the Value you can easily change the BackColor accordingly.e.g.

        Dim checked As Boolean = False
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            For i As Integer = 0 To FpSpread1.Sheets(0).RowCount - 1
                checked = FpSpread1.Sheets(0).Cells(i, 2).Value
                If checked = False Then
                    FpSpread1.Sheets(0).Cells(i, 2).BackColor = Color.Blue
                Else
                    FpSpread1.Sheets(0).Cells(i, 2).BackColor = Color.White
                End If
            Next
        End Sub

    I hope it helps.

    Thanks,

     

     

  • Replied 8 September 2017, 2:02 pm EST

    Hello Deepak,


    Thanks for your response. What I am trying to do is set something at the column level so that I don't have to spin through all of the cells and test them individually.

  • Replied 8 September 2017, 2:02 pm EST

    Hello,

    There has to be a check for the individual Cell, whether it is checked or not, I don't think there is a way to get to know about the Cell value on Column Level.

    However you can set the BackColor Of Column, leaving the Checked Cells with white BackGround but then also you will have to Check at the Cell Level for Checked Cells.

     

     

    Thanks,

     

     

  • Replied 8 September 2017, 2:02 pm EST

    Gary,


    You can use ConditionalFormats to implement this.


      Dim blueColor As New FarPoint.Win.Spread.NamedStyle
      blueColor.BackColor = Color.Blue
      FpSpread1.NamedStyles.Add(blueColor)
      FpSpread1.Sheets(0).SetConditionalFormat(-1, 1, blueColor, ComparisonOperator.IsTrue)

  • Replied 8 September 2017, 2:02 pm EST

    Thanks Scott! That is what I was looking for...
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels