Subject Re: [IBO] TIB_GRID, OnGetCellProps and BufferFields
Author Helen Borrie
At 04:15 AM 25/05/2004 +0000, you wrote:
>Using IBO4.3Aa, D6, FB 1.5.
>In TIB_GRID the onGetCellProps event handler allows me to set the
>background color and the font color for each column in the grid. I am
>using this event handler to set these colors depending on field data
>in the current row. The grid data comes from a TIB_Query, myQuery.
>The event handler is called with column and row numbers ACol and ARow
>where ARow is the row number of a visible row. To examine the data in
>the row when the event handler is called I must use
>myQuery.BufferFieldsByName(myFieldName).asWhatever (*)
>to examine the data field of the current row. The grid has
>FixedDataCols fixed data columns set in the published grid properties.
>The data returned by (*) in the event handler is for the current row
>for those columns numbered by Acol (FixedDataCols+2) and greater but
>contains the data for the previous row for columns 1,2,...
>(FixedDataCols+1). This is the source of my problem.
>I have made the following changes to IB_GRID.PAS
>{ Methods }
>{start changes by russell}
> function PublicColWidths(I:integer):integer;
> procedure PublicColWidthsChanged;
>{end changes by russell}
>{start changes by russell}
>function TIB_CustomGrid.PublicColWidths(I:integer): integer;
> Result := colWidths[I];
>procedure TIB_CustomGrid.PublicColWidthsChanged;
> ColWidthsChanged;
>{end changes by russell}
>I would have backed out these changes and then tested but the changes
>required to my code after backing out theses changes to IB_GRID.PAS
>are many, and I am guessing these changes have not upset the code in
>So I am submitting my problem here in the hope of saving time.
>Is the behaviour of BufferFieldsByName(..) descibed above intended?
>If not how can it be changed? If correct how can I get the correct
>data for low numbered columns in the event handler?

Why not just refer to the Columns property of the ib_row? (In this case,
BufferFields or Fields...since you are handling the current row, they are
the same). Columns is an array of TIB_Column, so, as long as your
FixedCols stay fixed, you can read from/write to the DisplayWidth property
of the data column. When you write to DisplayWidth, the grid will react