Subject Re: [IBO] Coloring an entire row in TIB_Grid
Author clatu_earth
--- In IBObjects@yahoogroups.com, Lucas Franzen <luc@r...> wrote:
>
> Alexandre,
>
> clatu_earth schrieb:
> > Hi!
> >
> > Anyone please can tell me what's wrong with the following piece of
> > code:
> >
> > void __fastcall TForm1::IB_Grid1GetCellProps(TObject *Sender,
> > int ACol, int ARow,
> > TGridDrawState AState, TColor &AColor, TFont *AFont)
> > {
> > if (IB_Qry1->Active && ACol > 0 && ARow >= IB_Grid1->FixedRows)
> > {
> > if (IB_Qry1->BufferFieldByName("PEND")->AsString == "YES")
> > AColor = clLime;
> > }
> > }
>
> I just have Delphi, so you have to convert the code back to C, but
> coloring a row in a TIB_Grid is - for me - working that way:
>
> with IB_Qry1 do
> begin
> if Active AND ( ACol > 0 ) AND ( aRow > 0 ) then
> begin
> BufferRowNum := IBGrid1.DataRow[ ARow ];
> if BufferRowNum > 0 then
> begin
> if AFont.Color <> clHighlightText then
> begin
> if BufferFieldByName('SOMEFIELD').AsString = SomeValue
> then aColor := clSomeColor
> else aColor := clSomeOtherColor;
> end;
> end;
> end;
> end;
>
> HTH
>
> Luc.

The problem was I missed the following:

BufferRowNum := IBGrid1.DataRow[ ARow ];

That are used to sync the dataset buffer with the Grid buffer.

Thanks Luc!