Subject Re: [IBO] tib_grid title color for sorted column
Author stanw1950
Geoff, thanks. The code works great. I think I like the title colored
better than the whole column. Jason - how about another a tib_grid
property - OrderingTitleColor.


--- In IBObjects@y..., Geoff Worboys (TeamIBO) <geoff@t...> wrote:
> 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);
> begin
> 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;
> end;
>
> 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
> prepared.
>
> hth
>
> --
> Geoff Worboys - TeamIBO
> Telesis Computing