Subject Re: [IBO] TIB_GRID, OnGetCellProps and BufferFields
Author Helen Borrie
Russell,

At 08:18 PM 25/05/2004 +0000, you wrote:

>What is intended?
>
>I want to paint the background color and font color for each row in
>the grid based on the data in the row. The painting is done inside
>the OnGetCellProps event handler. Input to this handler includes
>ARow, Acol (specifying the cell)
>and output includes
>AFont (for the text in the cell) and AColor (for the cell background
>color).
>
>The ARow values are relative to the top of the visible grid. ARow=1
>is the first visible row and so on. I am not sure yet what the ACol
>numbers are relative to, and the problem sems to lie with how the
>BufferFields are reset with respect to ACol values.
>
>The OnCellGetProps event is fired whenever the class needs to repaint
>a cell (I don't know all the details).
>
>The calls to the event handler are done, observing the Arow, Acol
>values sent, from what appear to be a loop like
> for ARow= RowStart to RowEnd
> for Acol = colStart to colEnd
> call handler(Arow, Acol, ...)
>
>
>When the handler is entered the object associated with the grid, that
>I know of, which contains best possible data for the row of the grid
>specified by ARow is
>myQuery.BufferFieldByName(myFieldName) (*)
>By observation and instrumenting the data (writing to a DB log file)
>I see that these (*) values are those for Row = ARow-1 when ACol is
>between 0 and (FixedDataCols+1) (they are one row behind) and are for
>row=Arow for Acol between (FixedDataCols+2) upwards (they ar for the
>current row and "correct") FixedDataCols is a property of the grid.
>
>My problem? When in the event handler which data object contains data
>for the row ARow?

OK, now I see the problem. Underlying it is the fact that there are
multiple row objects for any given row context, as you no doubt know, and
multiple indexes around for column orderings. I think you should avoid
FieldsIndex, because it doesn't reflect either the grid or the dataset
column indexes, but the override column orderings.

>Have I looked at Gridlinks? Not for this purpose but will now.

Possibly Gridlinks will propagate confusion, too, since it is an override
for FieldsIndex, which is itself an override for the actual order
determined by the statement's Fields[] array.

Just looking through the properties, I see GridCol and DataCol as
properties that could serve you here. GridCol returns the grid column
number, given the dataset column number; DataCol does the reverse.

Helen