ForeColor and binding

Posted by: sgmicro on 8 September 2017, 1:39 pm EST

  • Posted 8 September 2017, 1:39 pm EST

    Hello,


     How could I change foreColor for some row in my spread when i use Binding (grd.ActiveSheet.DataSource =...). In fact, i want set red color on any row whos has "X" in column number 3.


     Thks


     

  • Replied 8 September 2017, 1:39 pm EST

    I think it doesn't work in my case. I want change foreColor for all cells of a row if 3th column of this row set to X



     Col1  ! Col2 ! Col3 ! Col4 ! Col5 ! Col6 !
    -------+------+------+------+------+------!

    Line 1 !  A   !  B   !    !  C   !  D   ! 
    Line 2 !  A   !  B   !  U   !  C   !  D   !
    Line 3 !  A   !  B   !  X   !  C   !  D   !
    Line 4 !  A   !  B   !  Y   !  C   !  D   !

  • Replied 8 September 2017, 1:39 pm EST

    FpSpread1.ActiveSheet.Cells(0, 3).Text = "X"
    FpSpread1.ActiveSheet.Cells(2, 3).Text = "X"
    FpSpread1.ActiveSheet.Cells(4, 3).Text = "X"

    Dim ns As New FarPoint.Win.Spread.NamedStyle
    ns.ForeColor = Color.Red
    FpSpread1.NamedStyles.Add(ns)

    FpSpread1.ActiveSheet.SetConditionalFormat(-1, 3, ns, FarPoint.Win.Spread.ComparisonOperator.EqualTo, "T(""X"")")
  • Replied 8 September 2017, 1:39 pm EST

    babe59 -

    The easiest thing to do would be to use the SetConditionalFormat method after you are done with your binding.

  • Replied 8 September 2017, 1:39 pm EST

    If I don't make a mistake, only 3th column set to red foreColor. the other column have default forecolor (Black)


     

  • Replied 8 September 2017, 1:39 pm EST

    If this is your requirement then the ConditionalFormat will not work.  You will have to query the value of the cell and if it is an 'X' then set the forecolor for the entire row.
  • Replied 8 September 2017, 1:39 pm EST

    with your code I obtain that :


     Col1  ! Col2 ! Col3 ! Col4 ! Col5 ! Col6 !
    -------+------+------+------+------+------!
    Line 1 !  A   !  B   !  X   !  C   !  D   ! 
    Line 2 !  A   !  B   !  U   !  C   !  D   !
    Line 3 !  A   !  B   !  X   !  C   !  D   !
    Line 4 !  A   !  B   !  Y   !  C   !  D   !


    just "Col4" in red forecolor...

Need extra support?

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

Learn More

Forum Channels