Subject Re: OnDrawCell handler
Author Ingo Jansen
Hi Tomas,

i have the same problem when i want to draw a image in the cell. I
changed my code that way that dont use the dataset.fieldbyname
('').value, i use something like this -
if strtoInt(TIB_Grid(Sender).GetCellDisplayText(aCol,ARow))=2 then
begin
TIB_Grid(Sender).Canvas.Font.Color := clRed;
TIB_Grid(Sender).DefaultDrawCell(ACol, ARow, Rect, State,...
end;
and then i the problem was solved. i hope it's a solution for your
prolem too.

--- In IBObjects@egroups.com, Tomas MichalĂ­k <michalik@p...> wrote:
> Hi all,
>
> It is the first time I tried to do custom drawing in grid and I
haven't
> succeded :-(
> Here is the handler - it is only test:
>
> procedure TfTransfer.IB_Grid1DrawCell(Sender: TObject; ACol, ARow:
> Integer;
> Rect: TRect; State: TGridDrawState);
> begin
> if TIB_Grid(Sender).DataSource.Dataset.Active then
> begin
> if TIB_Grid(Sender).GridFields[ACol-1].FieldName
= 'PRP_MNOZSTVI'
> then
> if
> TIB_Grid(Sender).DataSource.Dataset.FieldByName
('PRP_MNOZSTVI').AsCurrency
> = 2 then
> begin
> TIB_Grid(Sender).Canvas.Font.Color := clRed;
> TIB_Grid(Sender).DefaultDrawCell(ACol, ARow, Rect, State,
>
> TIB_Grid(Sender).DataSource.Dataset.FieldByName
('PRP_MNOZSTVI').AsString,
> taCenter);
> end;
> end;
> end;
>
> I want to change the font color to clRed in all the cells where the
> value of column PRP_MNOZSTVI is 2. My code works in a different
way. It
> changes the font color only when the row that meets the condition is
> active/selected. But in such a case it changes the font color and
fills
> this value into all rows for this column.
> How do I get the actual field values for the row that is currently
being
> painted in a grid ?
>
> P.S. I think it worked when I used similar solution long time ago
with
> TDBGrid and TTable.
>
> Best regards,
> Tom
>
> =================================
>
> Tomas Michalik
> ProCA, s. r. o.
> V Luzich 818, Praha 4
> Czech Republic
>
> e-mail: michalik@p...
> tel: +420 2 67283446