Regarding Conditional formatting

Posted by: vishnupriya on 8 September 2017, 2:09 pm EST

  • Posted 8 September 2017, 2:09 pm EST

    Hi,


    I am using spread for windows form 4 in C#.net. I would like to know the conditional formatting functioanlity in the below case?


    I have one column with the boolean value (Yes / NO). Depending upon this column value I need to set the formatting in the second column(Background color change , Font change etc).


    And I want to set it for the full column at once.


    Please let me know whether it is possible or not? If possible how I can do that?


    Thanks in advance.
    Vishnupriya

  • Replied 8 September 2017, 2:09 pm EST

    Vishnupriya, yes this can be done. To set the conditional format for the entire column, you should set the row parameter as -1 in the SetConditionalFormat method of the Sheet.


    [Code]


    FarPoint.Win.Spread.NamedStyle styleCold = new FarPoint.Win.Spread.NamedStyle(); 
    styleCold.BackColor = Color.Blue;
    styleCold.ForeColor = Color.White; 
    fpSpread1.ActiveSheet.SetConditionalFormat(-1, 1, styleCold, FarPoint.Win.Spread.ComparisonOperator.LessThan, "32");  
    fpSpread1.ActiveSheet.Cells[1, 1].Value = 38;


    [End of code]


    Thanks,


    ~Jacob

  • Replied 8 September 2017, 2:09 pm EST

    Thanks Jacob for your promt reply.


    But I want to compare the value with the other column value. Can you please let me know how I can do that?


    I have first column "Status" which is  a boolean value(Yes/No). Depending on that entire first column values I need to change the entire second column formatiing ( back color change , font changes etc..). How I can do that?


    Thanks in advance 


     Vishnupriya


     

  • Replied 8 September 2017, 2:09 pm EST

    Vishnupriya,

    You can set the first column as combo box column and depending upon the value of first column cell, you can set the 2nd column settings e.g. backcolor, font etc:

    <blockquote>

     {
         string[] cbstr = null;
         cbstr = new string[] { "Yes", "No" };
         FarPoint.Win.Spread.CellType.ComboBoxCellType combo = new FarPoint.Win.Spread.CellType.ComboBoxCellType();
         combo.Items = cbstr;
         FpSpread1.Sheets(0).Columns(0).CellType = combo;
     }

     {
       
         if (FpSpread1.Sheets(0).Cells(0, 0).Value == "Yes") {
             FpSpread1.Sheets(0).Columns(1).BackColor = Color.Yellow;
         }
         else {
             FpSpread1.Sheets(0).Columns(1).BackColor = Color.Red;
         }
     }

    </blockquote>

    I have used the backcolor code snippet on a button click event. Hope this helps. Thanks

  • Replied 8 September 2017, 2:09 pm EST

    Hi Suresh,


    Thank you for your reply.


    In the above condition we are checking each cell value in the first column and updating the second column. But if we have thousands of rows there may be a performance issues.


    So can you please let me know Is there any other way to set the conditional formatting of one column based on another column values using <FONT size=2>SetConditionalFormat or any other method</FONT>?


    Thanks in advance


    Vishnupriya

  • Replied 8 September 2017, 2:09 pm EST

    Vishnupriya,

    There is nothing at column levels to compare(e.g. Column(0).Value), you can compare other properties of columns but not values, you need to iterate through all the cells(Cell(0,0).Value) of the column to compare the values.

    Thanks

Need extra support?

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

Learn More

Forum Channels