Subject Re: [IBO] Colors in Grid
Author andygarneruk
Thomas' helpful reply below colors, I believe, the whole of the grid
row. I would like to color just the specific cell that holds an
exception value. I have discovered I can do this by adding, for
example ... if ACol = 4 ... to Thomas' code, but if would like this
to be dependent on field name rather than column position.

How, in the the OnGetCellProps event can I check the name of the
query column that is being displayed in column ACol please?

Thanks for any suggestions, Andy.

Helen wrote:
>have you investigated the OnDrawCell event?

Ross wrote:
> > Yes. I assumed it would require coding. I don't see how you can
> > get the current column or row being drawn in the on OnDrawCell
> > event.

> Thomas wrote:
> I'm using the OnGetCellProps event. Dependent of a column value
> the font and background color is set.
> An example (not fully checked, but you might get the idea):
> procedure TfmMainForm.IB_Grid1GetCellProps(Sender: TObject; ACol,
ARow: Integer; AState: TGridDrawState; var AColor: TColor; AFont:
> TFont);
> begin
> with IB_Query1 do begin
> if Active and (ARow > 0) and (ACol > 0) then begin
> BufferRowNum := IB_Grid1.DataRow[ARow];
> if (BufferRowNum > 0) then begin
> if not (gdSelected in AState) then begin
> AFont.Color := BufferFieldByName('FONTCOLOR').AsInteger;
> AColor := BufferFieldByName('BACKGROUNDCOLOR').AsInteger;
> end;
> end;
> end;
> end;
> end;
> The Contact sample in %IBO%\Samples\Contact might be useful too.