Subject | OnDrawCell handler |
---|---|
Author | Tomas MichalĂk |
Post date | 2000-11-28T14:27:42Z |
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@...
tel: +420 2 67283446
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@...
tel: +420 2 67283446