Rows back and fore color

Posted by: koustubh on 8 September 2017, 1:28 pm EST

  • Posted 8 September 2017, 1:28 pm EST

    Sir i am using windows spread control for dot net 2.0 application.

    While populating data i set the row color as white and fore color as black and brown, but when user clicks the row i want to change the back color and forcolor for that selected row, for that i have written code to set back color as Black and fore color as yellow. When user select the row back color get assign to row but fore color didn't where i am going wrong please tell me.

  • Replied 8 September 2017, 1:28 pm EST

    How and where are you setting the colors up?  Did you try the SelectionBackColor and SelectionForeColor?
  • Replied 8 September 2017, 1:28 pm EST

    Hello Sir,

    While populating spread i am using folowing condition

    <FONT size=2>

    </FONT><FONT color=#0000ff size=2>if</FONT><FONT size=2> (conditin = </FONT><FONT color=#0000ff size=2>true</FONT><FONT size=2>)


    spread.Sheets[0].Rows[row].BackColor = </FONT><FONT color=#008080 size=2>Color</FONT><FONT size=2>.Black;


    </FONT><FONT color=#0000ff size=2>else

    </FONT><FONT size=2>


    spread.Sheets[0].Rows[row].ForeColor = </FONT><FONT color=#008080 size=2>Color</FONT><FONT size=2>.Brown;



    it is working fine, After cell click i use the following condition

    <FONT size=2>

    spread.Sheets[0].Rows[0, sp_queries.Sheets[0].RowCount - 1].BackColor = </FONT><FONT color=#008080 size=2>Color</FONT><FONT size=2>.White;

    spread.Sheets[0].Rows[0, sp_queries.Sheets[0].RowCount - 1].ForeColor = </FONT><FONT color=#008080 size=2>Color</FONT><FONT size=2>.Black;

    spread.Sheets[0].Rows[row].BackColor = </FONT><FONT color=#008080 size=2>Color</FONT><FONT size=2>.Black;

    spread.Sheets[0].Rows[row].ForeColor = </FONT><FONT color=#008080 size=2>Color</FONT><FONT size=2>.Yellow;

    </FONT>Here up to first 3 lines results is as per my expectation, but it is not setting fore color as yellow it setting it as a Black. 


  • Replied 8 September 2017, 1:28 pm EST

    In the CellClick event I did the following and it is working correctly..

    Private Sub FpSpread1_CellClick(ByVal sender As Object, ByVal e As FarPoint.Win.Spread.CellClickEventArgs) Handles FpSpread1.CellClick

    FpSpread1.ActiveSheet.Rows(e.Row).BackColor = Color.Black
    FpSpread1.ActiveSheet.Rows(e.Row).ForeColor = Color.Yellow

    End Sub

Need extra support?

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

Learn More

Forum Channels