Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
105
Conditional Formatting using database table for value reference
posted

I am having problems figuring out how to use Conditional Formatting in a case where I want cell values to be compared to values stored in another table and "linked" by a common field between the 2 tables.

Such as:

Table A

   Field A

   Field B

   Field C

   Field D

Table B

   Field A

   Field B

   Field C

   Field D

My grid uses Table A, and all it's fields.

But I want Field C and D Conditionally formatted based off Table B, Field C and D.

Table A, Field B holds Table B, Field A's value to link the two tables.

I want to set the background color of Table A, Field C to light green if Table A, Field C is between 90% and 95% of Table B, Field C, and set it to Dark Green if Table A, Field C is 95%-100% of Table B, Field C.

Same goes with Field D of both tables.

This needs to be done on a row by row basis I guess.

I'm not sure how to implement this.

  • 37774
    Verified Answer
    posted

    One approach of this would be to use a FormulaCondition, which requires an UltraCalcManager to be on your form; I believe that the grid Sample Explorer that ships with the NetAdvantage SDK includes sample on conditional formatting, which should include a FormulaCondition.  Your other option is to use the InitializeRow event, since Conditional Formatting really just provides a design-time tool to do what could already be done in InitializeRow.  Basically, in this event handler you could check the value of each cell against the value of the corresponding cells in other tables and change the Appearance accordingly.  I would also recommend that you create a single instance of each appearance object that you'll require (i.e. one for DarkGreen, one for LightGreen, etc) and re-use these instances for setting the appearances, so that you don't have to unnecessarily create multiple instances of essentially the same object.

    -Matt