TDBGrid(s) Compare Values and Paint

On this form, there are (3) TDBGrids. OnCalcCellColors  or OnDrawDataCell, need to compare a value in grid1 with a corresponding value in grid3. The row color for all (3) grids will be determined by the comparison. >= Red, < Green etc...

The coloring is easy. However without ARow & ACol cell references, not sure how to index the values. Works great on a single grid.
Doing the comparison in this manner with negate the need to  Enumerate the data set.
Greg RowlandSoftware Designer, SysDBA, WebMaster OwnerAsked:
Who is Participating?
Geert GOracle dbaCommented:
i'm missing a few items

you have 3 grids and 1 comparison between grid 1 and 3 ?
why do you need grid 2 then ?
Greg RowlandSoftware Designer, SysDBA, WebMaster OwnerAuthor Commented:
This is an Accounts Payable screen.

Grid1 holds the purchase order detail
Grid2 gets a copy of the purchase order data when a vendor invoice is entered
Grid3 holds the total paid on each line items, many times we get multiple Vendor Invoices on a single PO, and not all items may be received in one shipment.

The idea is to compare the Purchase Order Received Quantity and Approved amount, and total paid.
An attempt to enter an invoice amount in excess of the (Approved-Paid) with not be allowed.
line items paid in full will be colored red, those with remaining balances Green. Line items with no prices on the PO yellow.

I've done this sort of thing in a single grid before and it works great,OnCalcCellColors get called all the time. So the color updates seamlessly with keystrokes, also eliminating the need to enumerate that data sets.

Due to the way the data is laid out, evaluating the data row by row is really convenient as we always know which row the user is in.
Geert GOracle dbaCommented:
You are stating facts , when are the questions coming with the code ?
Greg RowlandSoftware Designer, SysDBA, WebMaster OwnerAuthor Commented:
The objective is to colorize all corresponding grid rows, based on ((Auth.AMt+Tot.Cost) <= Paid).
Just not sure how to go about it. Easily done in a String Grid or Single Grid.
And thank you Geert!
Greg RowlandSoftware Designer, SysDBA, WebMaster OwnerAuthor Commented:
Adding  Auth.Amt & Tot.Cost as lookup fields to Paid dataset made it work in that grid, however with a minor performance hit.
Unless we come up with a better idea, pretty well decided to simply maintain all three values in all three tables. Since these are all ClientDataSets, the only real hit will be storage, which in my environment is a non-issue. Still open to suggestions
All Courses

From novice to tech pro — start learning today.