ForeColor and binding

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

  • Posted 8 September 2017, 1:39 pm EST

    <P>Hello,</P>
    <P> 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.</P>
    <P> Thks</P>
    <P> </P>
  • Replied 8 September 2017, 1:39 pm EST

    <P>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</P>
    <P><BR><FONT face="courier new,courier"> Col1  ! Col2 ! Col3 ! Col4 ! Col5 ! Col6 !<BR>-------+------+------+------+------+------!</FONT><FONT face="courier new,courier"><BR><FONT color=#cc0000>Line 1 !  A   !  B   !  <STRONG>X </STRONG>  !  C   !  D   !</FONT> <BR>Line 2 !  A   !  B   !  U   !  C   !  D   !<BR><FONT color=#cc0000>Line 3 !  A   !  B   ! <STRONG> X</STRONG>   !  C   !  D   !</FONT> <BR>Line 4 !  A   !  B   !  Y   !  C   !  D   !</FONT></P>
  • Replied 8 September 2017, 1:39 pm EST

    FpSpread1.ActiveSheet.Cells(0, 3).Text = "X"<br>FpSpread1.ActiveSheet.Cells(2, 3).Text = "X"<br>FpSpread1.ActiveSheet.Cells(4, 3).Text = "X"<br><br>Dim ns As New FarPoint.Win.Spread.NamedStyle<br>ns.ForeColor = Color.Red<br>FpSpread1.NamedStyles.Add(ns)<br><br>FpSpread1.ActiveSheet.SetConditionalFormat(-1, 3, ns, FarPoint.Win.Spread.ComparisonOperator.EqualTo, "T(""X"")")
  • Replied 8 September 2017, 1:39 pm EST

    <p>babe59 -</p><p>The easiest thing to do would be to use the SetConditionalFormat method after you are done with your binding. <br></p>
  • Replied 8 September 2017, 1:39 pm EST

    <P>If I don't make a mistake, only 3th column set to red foreColor. the other column have default forecolor (Black)</P>
    <P> </P>
  • 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.<br>
  • Replied 8 September 2017, 1:39 pm EST

    <P>with your code I obtain that :</P>
    <P> <FONT face="Courier New">Col1  ! Col2 ! Col3 ! Col4 ! Col5 ! Col6 !<BR>-------+------+------+------+------+------!<BR><FONT color=#000000>Line 1 !  A   !  B   ! <FONT color=#cc0000> </FONT><STRONG><FONT color=#cc0000>X</FONT> </STRONG>  !  C   !  D   ! <BR>Line 2 !  A   !  B   !  U   !  C   !  D   !<BR>Line 3 !  A   !  B   ! <STRONG> <FONT color=#cc0000>X</FONT></STRONG><FONT color=#cc0000> </FONT>  !  C   !  D   ! <BR>Line 4 !  A   !  B   !  Y   !  C   !  D   !</FONT></FONT></P>
    <P><FONT face="Courier New">just "Col4" in red forecolor...</FONT></P>
Need extra support?

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

Learn More

Forum Channels