Subject Re: [IBO] tib_grid title color for sorted column
Author TeamIBO
Stan (and anyone else that is interested),

The code that I posted earlier was making some incorrect assumptions,
based on a misunderstanding that I had about the DataCol property.

After investigation I discovered that IB_Grid.DataCol is used to
translate a grid column number in an index into the list of IB_Columns
AS USED IN IB_GRID - the IB_Grid.GridFields property. (And not an
index into the dataset as I original thought). Whoops, sorry.

The correct code is...

procedure TForm1.IB_GridGetCellProps(Sender: TObject; ACol,
ARow: Integer; AState: TGridDrawState; var AColor: TColor;
AFont: TFont);
if (ARow < IB_Grid.FixedRows) and
(ACol >= IB_Grid.FixedCols) and
(IB_Query.OrderingItemNo <> 0) and
(IB_Grid.GridFields[IB_Grid.DataCol[ACol]].Index =
IB_Query.OrderingField.Index) then
AColor := clLime;

This works even when the GridLinks are defined showing columns in a
different order to what is defined in the dataset.

I dont think there should be any need to check IB_Query.Prepared,
since the ACol will only be >= IB_Grid.FixedCols when he query is


Geoff Worboys - TeamIBO
Telesis Computing